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

Enable internal classes #43

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

anotherthomas
Copy link

To facilitate API design for assemblies, [GenerateAutomaticInterface] should take internal visibility into account. The interface can be useful for dependency injection without necessarily being part of the public API of an assembly.

@ChristianSauer
Copy link
Collaborator

I like it, can you do a few things:

  1. Add tests for all relevant cases (no modifies, public, private, internal, protected?) Ideally add another partial class for that, the current test class is a "little" long.
  2. Bump the version to next major - this is a breaking change
  3. Mention it in the readme

Thanks!

@anotherthomas
Copy link
Author

Sure thing

@anotherthomas
Copy link
Author

So, working on the broader topic, what would we want to have?
Going over https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/access-modifiers:

  • public and internal classes ✔️
  • nested classes other than public/internal ❓ , but I don't see the use case

Wrt. nested members:

  • restrict to public within public classes ✔️
  • public and protected in protected classes ❓

What are your thoughts on that?

@ChristianSauer
Copy link
Collaborator

Sorry, I was occupied :(
After reading - i would say both question marks are out of scope for now. Let's start with the simple stuff...

@anotherthomas
Copy link
Author

Tests split, version bumped :)

Copy link
Collaborator

@ChristianSauer ChristianSauer left a comment

Choose a reason for hiding this comment

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

Overall I like it.
But it does not yet touch nested classes if I see it correctly?

@@ -25,7 +25,7 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<EnableNETAnalyzers>True</EnableNETAnalyzers>
<AnalysisLevel>latest-Recommended</AnalysisLevel>
<Version>2.3.0</Version>
<Version>3.0.0</Version>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, definitely needed.
I would suggest also adding examples, changelog and your name to Readme.md - especially calling out that you fixed a bug where classes without access modifier where wrongly set to public instead of internal.

Copy link
Author

Choose a reason for hiding this comment

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

Good point!


public partial class AccessibilityTests
{
private static string GenerateCode(string code)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm, this dublicates code in the original tests.
Maybe use the same partial class tests I've used like in AutomaticInterface/Tests/GeneratorsTests.MethodParameters.cs?

}

[Fact]
public void AddsPublicMethodToInterface()
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does this test test?
Seems to me already tested by existing tests?

}

[Fact]
public void WorksWithInternal()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see internal here?

}

[Fact]
public void WorksWithDefaultAccessModifier()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like the above test?

@anotherthomas
Copy link
Author

Sorry, had several things on my plate those last few months. Still interested?

@ChristianSauer
Copy link
Collaborator

Yes! You need probably to rebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants