Skip to content

Doc fixes #606

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

Merged
merged 1 commit into from
Mar 4, 2020
Merged

Doc fixes #606

merged 1 commit into from
Mar 4, 2020

Conversation

dtchepak
Copy link
Member

  • Fix links to NSubstitute.Analyzers docs in "How NSubstitute Works" doc.
  • For Docs: fix overridable member documentation #599, the docs are referring to real code executing for
    non-overridable members, which includes protected virtual code, even
    if these calls are not (easily) configurable via the NSubstitute API.
    Have attempted to clarify by:
    • updating "Getting Started" to not give specifics, and just link to
      more info in "Creating a sub" so this information is centralised and
      consistent. Also adds more advice to install Analyzers.
    • update "Creating a sub" to mention configuration can only be via
      callable API.

@alexandrnikitin or @zvirja, can one of you please take a quick proof-read and make sure this makes sense?

- Fix links to NSubstitute.Analyzers docs in "How NSubstitute Works" doc.
- For nsubstitute#599, the docs are referring to real code executing for
  non-overridable members, which includes `protected virtual` code, even
  if these calls are not (easily) configurable via the NSubstitute API.
  Have attempted to clarify by:
  + updating "Getting Started" to not give specifics, and just link to
    more info in "Creating a sub" so this information is centralised and
    consistent. Also adds more advice to install Analyzers.
  + update "Creating a sub" to mention configuration can only be via
    callable API.
Copy link
Contributor

@zvirja zvirja left a comment

Choose a reason for hiding this comment

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

Looks great!

@@ -15,7 +15,7 @@ This is how you'll normally create substitutes for types. Generally this type wi

⚠️ **Warning:** Substituting for classes can have some nasty side-effects!

For starters, **NSubstitute can only work with *virtual* members of the class** that are overridable in the test assembly, so any non-virtual code in the class will actually execute! If you try to substitute for a class that formats your hard drive in the constructor or in a non-virtual property setter then you're asking for trouble. (By overridable we mean `public virtual`, `protected virtual`, `protected internal virtual`, or `internal virtual` with `InternalsVisibleTo` attribute applied. See [How NSubstitute works](/help/how-nsub-works) for more information.)
Copy link
Member

Choose a reason for hiding this comment

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

This still has protected virtual in the doc. I thought we wanted to remove it. Am I missing something?

Copy link
Member Author

Choose a reason for hiding this comment

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

I admit this is confusing. These docs are referring to real code executing for non-overridable members, which includes protected virtual code, even if these calls are not (easily) configurable via the NSubstitute API. It's not about what methods we can configure with NSub -- it's about what real code can execute.

There is probably a better way to communicate this. 🤔

@dtchepak dtchepak merged commit a6eab0e into nsubstitute:master Mar 4, 2020
@dtchepak dtchepak deleted the doc-fixes branch March 4, 2020 03:25
dtchepak added a commit to nsubstitute/nsubstitute.github.com that referenced this pull request Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants