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

Issue with error CS0114 and CS0109 #63821

Closed
JRahnama opened this issue Sep 6, 2022 · 1 comment
Closed

Issue with error CS0114 and CS0109 #63821

JRahnama opened this issue Sep 6, 2022 · 1 comment
Assignees
Labels
Area-Compilers Bug Resolution-Not Applicable The issue is not relevant to code in this repo and is not an external issue.
Milestone

Comments

@JRahnama
Copy link

JRahnama commented Sep 6, 2022

Hi, I am from SqlClient team and noticed an odd behavior.

In SqlTransaction we have two functions for Rollback and one function for Save.

One of the Rollback functions is overriding the base class DbTransaction and has no arguments provided. The other one shares the same name(Rollback) but takes an argument of string type.

The Save method is taking an argument of string type therefore is not overriding any class from its parent.

When we try to build the driver we get an error message saying CS0114. I followed the suggestion, although it is not hiding any method, and tried to rebuild the driver and got error CS0109. It seems like a loop. When I suppressed the errors in editorconfig file I was able to build the driver.

Net6.0.400

Steps to Reproduce:

  1. Clone net6 branch from PR#1704
  2. Take the rules for CS0109 and CS0114 out of .editorconfig file
  3. try building the driver by msbuild and you will see the problem. VS2022 does not show that error.

Expected Behavior:
Since the driver does not hide any method we should not get that error when building with msbuild

Actual Behavior:
Error CS0114 and CS0109 are thrown in alternately.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Sep 6, 2022
@JRahnama JRahnama changed the title Hi, Issue with error CS0114 and CS0109 Sep 6, 2022
@jaredpar jaredpar added Bug and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Sep 7, 2022
@jaredpar jaredpar added this to the 17.4 milestone Sep 7, 2022
@333fred
Copy link
Member

333fred commented Sep 7, 2022

@JRahnama it looks like System.Data.Common.DbTransaction added Rollback(string) and Save(string) methods in .NET 5.0: https://apisof.net/catalog/ddd17df1-e088-f946-1352-b791d1491706 and https://apisof.net/catalog/40ee19c8-80bb-173d-b731-e89d3ff7e382. Because of this, you are getting different warnings when targeting different frameworks. You can either suppress the warnings as you're doing now, or you can conditionally apply the new keyword via #ifdef like so:

        /// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlTransaction.xml' path='docs/members[@name="SqlTransaction"]/Rollback2/*'/>
        public
#if NET5_0_OR_GREATER
            new
#endif
            void Rollback(string transactionName)
        { }
        /// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlTransaction.xml' path='docs/members[@name="SqlTransaction"]/Save/*'/>
        public
#if NET5_0_OR_GREATER
            new
#endif
            void Save(string savePointName)
        { }

@333fred 333fred closed this as completed Sep 7, 2022
@333fred 333fred closed this as not planned Won't fix, can't repro, duplicate, stale Sep 7, 2022
@333fred 333fred added the Resolution-Not Applicable The issue is not relevant to code in this repo and is not an external issue. label Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Bug Resolution-Not Applicable The issue is not relevant to code in this repo and is not an external issue.
Projects
None yet
Development

No branches or pull requests

3 participants