.NET Core is not enforcing class implements inherited interface









up vote
4
down vote

favorite
2












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.










share|improve this question









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 : 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














up vote
4
down vote

favorite
2












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.










share|improve this question









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 : 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












up vote
4
down vote

favorite
2









up vote
4
down vote

favorite
2






2





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.










share|improve this question









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






share|improve this question









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.











share|improve this question









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.









share|improve this question




share|improve this question








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 : 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
















  • 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















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












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






share|improve this answer








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










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






Danny Acosta is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















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






























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






share|improve this answer








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














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






share|improve this answer








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












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






share|improve this answer








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







share|improve this answer








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.









share|improve this answer



share|improve this answer






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












  • 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










Danny Acosta is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















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.













 


draft saved


draft discarded














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














































































這個網誌中的熱門文章

What does pagestruct do in Eviews?

Dutch intervention in Lombok and Karangasem

Channel Islands