.NET Core is not enforcing class implements inherited interface
up vote
4
down vote
favorite
I'm seeking some guidance with the following issue.
I have an Interface A with a method A.DoSomething
I have another interface B with a method B.DoSomethingElse. B Inherits from A
I have a class C that inherits from interface B
interface A
void DoSomething();
interface B : A
void DoSomethingElse();
public class C : B
public void DoSomethingElse()
//do something else here
If I write the above code in .NET Standard I get a compile time error stating that class C must implement interface A. However if I write the same code in .NET Core I don't get any compile time error to enforce the implementation of interface A in class C.
I'm using .NET Core 2.1 with Visual Studio Enterprise 2017 version 15.8.9.
c# visual-studio .net-core
New contributor
Danny Acosta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
4
down vote
favorite
I'm seeking some guidance with the following issue.
I have an Interface A with a method A.DoSomething
I have another interface B with a method B.DoSomethingElse. B Inherits from A
I have a class C that inherits from interface B
interface A
void DoSomething();
interface B : A
void DoSomethingElse();
public class C : B
public void DoSomethingElse()
//do something else here
If I write the above code in .NET Standard I get a compile time error stating that class C must implement interface A. However if I write the same code in .NET Core I don't get any compile time error to enforce the implementation of interface A in class C.
I'm using .NET Core 2.1 with Visual Studio Enterprise 2017 version 15.8.9.
c# visual-studio .net-core
New contributor
Danny Acosta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Just tried your code (same .NET core version and VS version) and I get the expected compile error.
– Klaus Gütter
16 hours ago
I've tried it as well and get the same error in .NET Core, .NET Standard and .NET Framework. I know it sounds silly but are you sure the inheritance is setup correctly in the .NET Core code? (It's easy to miss off the: Abut still think it's there...we've all done it at one time :-) ) Could you share your code in GitHub so we can see the full projects please?
– Simply Ged
15 hours ago
add a comment |
up vote
4
down vote
favorite
up vote
4
down vote
favorite
I'm seeking some guidance with the following issue.
I have an Interface A with a method A.DoSomething
I have another interface B with a method B.DoSomethingElse. B Inherits from A
I have a class C that inherits from interface B
interface A
void DoSomething();
interface B : A
void DoSomethingElse();
public class C : B
public void DoSomethingElse()
//do something else here
If I write the above code in .NET Standard I get a compile time error stating that class C must implement interface A. However if I write the same code in .NET Core I don't get any compile time error to enforce the implementation of interface A in class C.
I'm using .NET Core 2.1 with Visual Studio Enterprise 2017 version 15.8.9.
c# visual-studio .net-core
New contributor
Danny Acosta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I'm seeking some guidance with the following issue.
I have an Interface A with a method A.DoSomething
I have another interface B with a method B.DoSomethingElse. B Inherits from A
I have a class C that inherits from interface B
interface A
void DoSomething();
interface B : A
void DoSomethingElse();
public class C : B
public void DoSomethingElse()
//do something else here
If I write the above code in .NET Standard I get a compile time error stating that class C must implement interface A. However if I write the same code in .NET Core I don't get any compile time error to enforce the implementation of interface A in class C.
I'm using .NET Core 2.1 with Visual Studio Enterprise 2017 version 15.8.9.
c# visual-studio .net-core
c# visual-studio .net-core
New contributor
Danny Acosta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Danny Acosta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 17 hours ago
user2864740
43.1k669141
43.1k669141
New contributor
Danny Acosta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 17 hours ago
Danny Acosta
211
211
New contributor
Danny Acosta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Danny Acosta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Danny Acosta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Just tried your code (same .NET core version and VS version) and I get the expected compile error.
– Klaus Gütter
16 hours ago
I've tried it as well and get the same error in .NET Core, .NET Standard and .NET Framework. I know it sounds silly but are you sure the inheritance is setup correctly in the .NET Core code? (It's easy to miss off the: Abut still think it's there...we've all done it at one time :-) ) Could you share your code in GitHub so we can see the full projects please?
– Simply Ged
15 hours ago
add a comment |
Just tried your code (same .NET core version and VS version) and I get the expected compile error.
– Klaus Gütter
16 hours ago
I've tried it as well and get the same error in .NET Core, .NET Standard and .NET Framework. I know it sounds silly but are you sure the inheritance is setup correctly in the .NET Core code? (It's easy to miss off the: Abut still think it's there...we've all done it at one time :-) ) Could you share your code in GitHub so we can see the full projects please?
– Simply Ged
15 hours ago
Just tried your code (same .NET core version and VS version) and I get the expected compile error.
– Klaus Gütter
16 hours ago
Just tried your code (same .NET core version and VS version) and I get the expected compile error.
– Klaus Gütter
16 hours ago
I've tried it as well and get the same error in .NET Core, .NET Standard and .NET Framework. I know it sounds silly but are you sure the inheritance is setup correctly in the .NET Core code? (It's easy to miss off the
: A but still think it's there...we've all done it at one time :-) ) Could you share your code in GitHub so we can see the full projects please?– Simply Ged
15 hours ago
I've tried it as well and get the same error in .NET Core, .NET Standard and .NET Framework. I know it sounds silly but are you sure the inheritance is setup correctly in the .NET Core code? (It's easy to miss off the
: A but still think it's there...we've all done it at one time :-) ) Could you share your code in GitHub so we can see the full projects please?– Simply Ged
15 hours ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
this is the correct way to implement the interfaces
public class C : B
public void DoSomething()
//do something
public void DoSomethingElse()
//do something else here
New contributor
J.Oliver is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
4
Welcome to Stack Overflow. Although your answer is correct, it does not answer the question the user has asked. Please take some time to read How to Answer to understand what is required for a good quality answer.
– Simply Ged
15 hours ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
this is the correct way to implement the interfaces
public class C : B
public void DoSomething()
//do something
public void DoSomethingElse()
//do something else here
New contributor
J.Oliver is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
4
Welcome to Stack Overflow. Although your answer is correct, it does not answer the question the user has asked. Please take some time to read How to Answer to understand what is required for a good quality answer.
– Simply Ged
15 hours ago
add a comment |
up vote
0
down vote
this is the correct way to implement the interfaces
public class C : B
public void DoSomething()
//do something
public void DoSomethingElse()
//do something else here
New contributor
J.Oliver is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
4
Welcome to Stack Overflow. Although your answer is correct, it does not answer the question the user has asked. Please take some time to read How to Answer to understand what is required for a good quality answer.
– Simply Ged
15 hours ago
add a comment |
up vote
0
down vote
up vote
0
down vote
this is the correct way to implement the interfaces
public class C : B
public void DoSomething()
//do something
public void DoSomethingElse()
//do something else here
New contributor
J.Oliver is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
this is the correct way to implement the interfaces
public class C : B
public void DoSomething()
//do something
public void DoSomethingElse()
//do something else here
New contributor
J.Oliver is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
J.Oliver is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 15 hours ago
J.Oliver
1
1
New contributor
J.Oliver is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
J.Oliver is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
J.Oliver is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
4
Welcome to Stack Overflow. Although your answer is correct, it does not answer the question the user has asked. Please take some time to read How to Answer to understand what is required for a good quality answer.
– Simply Ged
15 hours ago
add a comment |
4
Welcome to Stack Overflow. Although your answer is correct, it does not answer the question the user has asked. Please take some time to read How to Answer to understand what is required for a good quality answer.
– Simply Ged
15 hours ago
4
4
Welcome to Stack Overflow. Although your answer is correct, it does not answer the question the user has asked. Please take some time to read How to Answer to understand what is required for a good quality answer.
– Simply Ged
15 hours ago
Welcome to Stack Overflow. Although your answer is correct, it does not answer the question the user has asked. Please take some time to read How to Answer to understand what is required for a good quality answer.
– Simply Ged
15 hours ago
add a comment |
Danny Acosta is a new contributor. Be nice, and check out our Code of Conduct.
Danny Acosta is a new contributor. Be nice, and check out our Code of Conduct.
Danny Acosta is a new contributor. Be nice, and check out our Code of Conduct.
Danny Acosta is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53236153%2fnet-core-is-not-enforcing-class-implements-inherited-interface%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Just tried your code (same .NET core version and VS version) and I get the expected compile error.
– Klaus Gütter
16 hours ago
I've tried it as well and get the same error in .NET Core, .NET Standard and .NET Framework. I know it sounds silly but are you sure the inheritance is setup correctly in the .NET Core code? (It's easy to miss off the
: Abut still think it's there...we've all done it at one time :-) ) Could you share your code in GitHub so we can see the full projects please?– Simply Ged
15 hours ago