Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Fix an overly broad C# access modifier by choosing the narrowest access level that still serves every legitimate caller. That may be private, internal, protected, or another level—not automatically private. Before changing a declaration, check inheritance, tests, framework conventions, generated code, reflection, and whether the type ships as a library.

What does “overly broad” access mean?

A member is overly broad when code outside its legitimate caller set can access it. This is usually a design or analyzer finding, not a compiler error: C# checks whether an access modifier is legal, but does not know which callers your design intends to support.

For example, this class exposes mutable state and an implementation detail to every consumer:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
public class InvoiceProcessor
{
    public decimal TaxRate { get; set; }
    public void RecalculateInternalState() { }
    internal object _cache = new();
}

If the setter and recalculation routine are only needed inside the class, and no other type needs the cache, narrow them:

#1 Best Overall
Gogoonike Adjustable Laptop Stand for Desk, Metal Laptop Riser Holder
  • 【Adjustable & Ergonomic】:This laptop stand can be adjusted to a comfortable height and angle according to your actual needs, letting you fix posture and reduce your neck fatigue, back pain and eye strain. Very comfortable for working in home, office and outdoor.
  • 【Sturdy & Protective】 :Made of sturdy metal, it can support up to 17.6 lbs (8kg) weight on top; With 2 rubber mats on the hook and anti-skid silicone pads on top & bottom, it can secure your laptop in place and maximum protect your device from scratches and sliding. Moreover, smooth edges will never hurt your hands.
  • 【Heat Dissipation】 :The top of the laptop stand is designed with multiple ventilation holes. The open design offers greater ventilation and more airflow to cool your laptop during operation other than it just lays flat on the table.
  • 【Portable & Foldable】:The foldable design allows you to easily slip it in your backpack. Ideal for people who travel for business a lot.
  • 【Broad Compatibility】:Our desktop book stand is compatible with all laptops from 10-15.6 inches, such as MacBook Air/ Pro, Google Pixelbook, Dell XPS, HP, ASUS, Lenovo ThinkPad, Acer, Chromebook and Microsoft Surface, etc.Be your ideal companion in Home, Office & Outdoor.
public class InvoiceProcessor
{
    public decimal TaxRate { get; private set; }
    private void RecalculateInternalState() { }
    private readonly object _cache = new();
}

“No references found outside the class” is useful evidence, not proof. Reflection, serializers, dependency injection, source generators, markup, ORMs, and plugin contracts can create consumers that a normal source search will not find.

Choose access by caller

C# has six member access levels. Choose based on who must call or inherit the member, not on which modifier seems safest in isolation. A member can never be more accessible than its containing type, and types exposed in its signature must be at least as accessible as the member. See Microsoft’s access modifier guide, accessibility-level reference, and accessibility restrictions.

Who needs access? Use
Only the declaring type private
The declaring type and derived types in the same assembly private protected
The declaring type and derived types in any assembly protected
Any code in the current assembly internal
Same-assembly code or derived types outside the assembly protected internal
Any consuming assembly public
Only the source file, for a top-level type (C# 11 or later) file

The distinction between protected internal and private protected matters: the first grants access to same-assembly code or derived classes outside the assembly; the second restricts derived-class access to the same assembly. See Microsoft’s summary of access domains.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Audit the member before changing it

  1. Identify the finding. Record the analyzer ID, project, target frameworks, and whether generated code is involved. Rule names, severity, and available fixes vary by analyzer and configuration.
  2. Search for consumers. Look through the solution, tests, samples, benchmarks, markup, configuration, generated-code inputs, and reflection-based string lookups—not just ordinary C# references.
  3. Classify each caller. Decide whether it is inside the declaring type, elsewhere in the assembly, a derived type, an external assembly, or a runtime or tooling consumer.
  4. Select the narrowest suitable modifier. Keep the broader level if a legitimate consumer needs it; do not turn every warning into a private declaration.
  5. Check language constraints. Review the containing type, signature types, overrides, interface implementations, partial declarations, accessor rules, and whether the member belongs to a struct.
  6. Make the edit. In Visual Studio, put the caret on the declaration and open Quick Actions and Refactorings with Ctrl+.. The available actions depend on the diagnostic and installed tooling; see Microsoft’s Quick Actions documentation.
  7. Build every affected project and target framework. A local project may not include consumers built by CI, such as samples, generated code, or downstream projects.
  8. Run relevant tests and integration checks. Include serialization, DI startup, reflection-based registration, source generation, and UI binding if the code uses them.
  9. Review the API diff before shipping a library. Use the library’s API review or compatibility process; a successful build of the library alone does not prove downstream compatibility.
  10. Explain exceptions. If broad access is required, document the consumer in a comment or a narrowly scoped analyzer suppression.

Common changes and when they fit

Replace a public field with controlled behavior

A public field lets every consumer read and write storage directly. For a reusable .NET library, Microsoft’s field design guidance recommends private fields so the internal representation can change without exposing it as part of the API.

Rank #2
WOLFBOX MegaFlow 50 Compressed Air Duster, 110,000 RPM, 3-Gear Adjustable
  • Powerful Turbo Fan:WOLFBOX MegaFlow 50 electric air duster reaches speeds of up to 110,000 RPM, effectively removing dust and debris. It features three adjustable speed settings to suit different cleaning tasks.
  • Economical and Reusable: Built from durable materials with a long-lasting battery, the WOLFBOX MegaFlow 50 is a sustainable alternative to disposable air cans, enhancing your cleaning experience.
  • Portable and Lightweight: Weighing only 0.45 lb, this compact air duster is easy to carry. The included lanyard ensures convenient use both indoors and outdoors.
  • Wide Application: WOLFBOX MegaFlow 50 electric air duster comes with 4 nozzles, making it suitable for a variety of scenes, such as pc, keyboards, or other electronic devices. It also serves well for home clean and car duster.
  • 3.5 Hours Fast Charging: WOLFBOX MegaFlow 50 electric air duster recharges in just 3.5 hours with a type-C cable. Enjoy up to 240 minutes of use on the lowest setting, with four charging options to suit your needs.To ensure optimal performance of your MF50, please fully charge the battery before use.
public class Counter
{
    public int Value;
}

If callers should read the value but change it only through an operation, keep the storage private:

public class Counter
{
    private int _value;
    public int Value => _value;

    public void Increment() => _value++;
}

Restrict a property setter

If consumers need to read a property but only the class should update it, use a private setter. If derived classes are responsible for updating it, a protected setter may be appropriate:

public string Name { get; private set; }

public string Status { get; protected set; }

A differing accessor modifier must be more restrictive than the property or indexer, and only one accessor may have a differing modifier. See Microsoft’s accessor accessibility rules.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Narrow an internal member

Change internal to private only when all real callers are in the declaring type. Check test projects and any InternalsVisibleTo friend assemblies first; those assemblies can access internal members even though they are separate projects.

Rank #3
Sale
Acer USB Hub 4 Ports, Multiple USB 3.0 Hub, USBA Splitter for Laptop/PC 2FT
  • 【4 Ports USB 3.0 Hub】Acer USB Hub extends your device with 4 additional USB 3.0 ports, ideal for connecting USB peripherals such as flash drive, mouse, keyboard, printer
  • 【5Gbps Data Transfer】The USB splitter is designed with 4 USB 3.0 data ports, you can transfer movies, photos, and files in seconds at speed up to 5Gbps. When connecting hard drives to transfer files, you need to power the hub through the 5V USB C port to ensure stable and fast data transmission
  • 【Excellent Technical Design】Build-in advanced GL3510 chip with good thermal design, keeping your devices and data safe. Plug and play, no driver needed, supporting 4 ports to work simultaneously to improve your work efficiency
  • 【Portable Design】Acer multiport USB adapter is slim and lightweight with a 2ft cable, making it easy to put into bag or briefcase with your laptop while traveling and business trips. LED light can clearly tell you whether it works or not
  • 【Wide Compatibility】Crafted with a high-quality housing for enhanced durability and heat dissipation, this USB-A expansion is compatible with Acer, XPS, PS4, Xbox, Laptops, and works on macOS, Windows, ChromeOS, Linux

Replace an unnecessarily broad protected internal member

Choose the needed part of the access domain: private protected for same-assembly derived classes, protected for derived classes across assemblies, or internal for same-assembly collaborators that do not need inheritance access.

Hide an implementation behind an interface

If a method must fulfill an interface contract but should not appear as a callable member on the concrete class, use explicit interface implementation:

public class Exporter : IDisposable
{
    void IDisposable.Dispose() { }
}

Callers can invoke this implementation through an IDisposable reference, not directly through an Exporter reference. Explicit interface members have no access modifier. See Microsoft’s explicit interface implementation guide.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Consider a file-local top-level type

When a top-level helper type is used only in one source file, file can express that boundary. It is available in C# 11 and later; verify the project’s language version before using it. It is not an access modifier for ordinary members.

Rank #4
Sale
OPNICE Desk Organizer and Accessories, 2-Tier Computer Monitor Stand Riser with Drawer and 2 Pen Holders, Laptop Stand, Office Desk Accessories for Office Supplies, Black
  • 【Ergonomic Design】:OPNICE newly releases the monitor stand for desk organizer! This computer stand elevates your monitor or laptop to a comfortable viewing height, relieving pressure on your neck, shoulders. Ideal for strengthening office organization and increasing comfort levels
  • 【Save Space】:This 2-Tier monitor stand with drawer and 2 hanging pen holders provides ample storage space to keep your office supplies and office desk accessories neatly organized and easily accessible, keeping your workspace tidy and improving your sense of well-being
  • 【Durable and Stable】:The metal computer stand is made of high quality material with sturdy construction, it can easily carry the weight of the display and computer accessories, to ensure stable and non-shaking for a long time, ideal for use in the office, dorm room or home
  • 【Sleek and Aesthetic】:This desktop organizer features a modern minimalist design that blends seamlessly with any office decor. It not only enhances functionality but also adds a touch of style and aesthetic to your workspace, making it an essential piece for your office organization efforts
  • 【Hassle-free Shopping】:OPNICE is committed to providing excellent after-sales service and offers a 100-day unconditional return policy for desk organizers and accessories. Comes with four non-slip pads that are height-adjustable to protect your table from scratches(U.S. Patent Pending)

When a modifier cannot simply be narrowed

  • Overrides: An override retains the accessibility of the base member; C# does not let the override change it. See the override reference.
  • Interface implementations: A normal implementation of a public interface member must satisfy that contract. Explicit implementation can keep it off the concrete type’s public surface. See Microsoft’s interface implementation diagnostics.
  • Virtual or abstract extension points: Narrowing a public or protected member can break derived consumers that rely on overriding or calling it.
  • Partial declarations: Declarations of the same partial type or member must agree on accessibility.
  • Struct members: Structs do not support inheritance, so their members cannot use protected, protected internal, or private protected.
  • Operators and enum members: User-defined operators must be public; enum members are implicitly public and cannot be assigned access modifiers.
  • Public signatures: A public member cannot expose a less-accessible parameter, return, or constituent type. The compiler rejects such declarations under the accessibility restrictions.

Check tests, frameworks, and generated consumers

Tests should normally verify observable behavior through the supported API. Do not make a production member public solely to simplify a unit test. If a test assembly genuinely needs access to implementation members, use InternalsVisibleTo and keep those members internal; Microsoft covers friend assemblies in its access modifier guidance.

Before reducing visibility, check consumers that may not appear in ordinary source references:

  • Serialization and persistence: System.Text.Json, Newtonsoft.Json, XML serializers, ORMs, and custom reflection code.
  • Framework discovery: ASP.NET model binding and conventions, dependency-injection activation, middleware discovery, and reflection-based registration.
  • UI and engines: WPF or WinUI/XAML bindings and event handlers, plus Unity or other engine serialization.
  • Build-time and deployment tooling: source generators, generated partial classes, COM integration, trimming, NativeAOT, and plugin contracts.
  • External callers: documentation, samples, downstream packages, and friend assemblies declared with InternalsVisibleTo.

If a framework needs access, prefer its supported registration mechanism, metadata, or serializer configuration rather than widening unrelated implementation members.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Distinguish an application refactor from a library API change

For an application rebuilt together with all its projects, reducing visibility is often a source refactor; the build and integration tests reveal ordinary callers that no longer compile or work. For a published library, narrowing a public member is a compatibility break: previously compiled consumers may encounter missing-member or type-load failures, and source consumers may fail to compile. Microsoft explains this in its guidance on breaking changes for .NET libraries and NuGet package compatibility.

Best Value
Office Desk Accessories 2pcs Computer Monitor Memo Board Office Supplies
  • [MULTIFUNCTIONAL]You'll get 2 pieces computer monitor memo boards that you can stick on the left and right edges of your monitor, and they're the perfect office desk organizers and accessories. Computer monitor side panels desktop organizer are suitable for home work or office,bringing convenience. Desktop memo is used to organize meeting memos, important messages, business cards, planning notes.Paste on the message board to keep track of important things and to-do items to prevent forgetting.
  • [🌟HIGHLY QUALITY] The material of computer screen side note holder is transparent acrylic. Durable, simple, stylish, light weight, easy to use, not easy to fall off or break. This cute office supplies for women desk can be used for a long time. This computer desk accessories is waterproof and dirt resistance, and look simple and stylish. The transparent acrylic sticky note holder as cubicle accessories is easy to notice the context of your sticky notes.
  • [📋Easy to use] Office must haves cool office gadgets for desk ready to tear, easy to install and remove, not easy to leave traces. You only need to peel off the protective film on the surface of the computer side board memo, wipe off the dust on the edge of the computer monitor, and then stick the desk essentials for women office on the right or left side of the tape, and you're done. A perfect gift for your colleagues, friends or classmates and family members or relatives
  • [🏢MULTI-SCENE USE] This desk supplies computer memo board can be applied to home and office, clear your office decor for women, suitable for most computer monitors, screens and cabinets, you can put it where you think, this cute office decor serve as a reminder. Stick on the computer side. It’s a good office gadgets can remind work improve office productivity. Pasted cabinets, dressers, refrigerators, walls, etc as cubicle accessories. To make life more orderly.
  • [💌NOTE] The adhesive force of the computer sticky note holder is very strong. It can not be directly pasted on the computer screen. It should pasted on the black edge of the screen. Narrow edge not recommended!!! If you are not satisfied with your purchase, or if the product is damaged or broken in transit, please let us know immediately. We will promptly solve your problem.

A safer migration is to mark the old member [Obsolete], add a replacement API, publish migration guidance, and remove the old member only in a planned major release if the library’s compatibility policy permits it.

Enforce the policy without trusting bulk fixes blindly

To require explicit access modifiers, add this to .editorconfig:

[*.cs]
dotnet_style_require_accessibility_modifiers = always

That setting addresses explicit modifiers, not whether a particular member should be public or private. To enforce code-style diagnostics during builds, enable EnforceCodeStyleInBuild and configure the relevant diagnostic severity; see Microsoft’s .NET code analysis overview.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Apply configured analyzer fixes with the documented dotnet format commands:

dotnet format analyzers MySolution.sln --severity warn
dotnet format style MySolution.sln --severity info

Treat the result as a reviewable code change. An analyzer or formatter cannot reliably infer reflection-based use, external API expectations, or every framework convention.

Troubleshoot a failed fix

  • The build fails after narrowing: Use compiler errors to identify callers, then decide whether those callers should be changed or the member should remain internal, protected, or broader.
  • Only CI fails: Check target frameworks, samples, generated code, analyzers, and projects not built locally.
  • Serialization or deserialization breaks: Use supported constructors or properties, explicit serializer metadata, or a custom converter instead of restoring broad fields by default.
  • Dependency injection stops activating a type: Register the type or factory explicitly, or use the constructor visibility supported by that framework.
  • A derived package breaks: Preserve the protected contract, or introduce a new protected hook and deprecate the old one through the library’s migration policy.
  • The analyzer still reports the member: Refresh generated files, check analyzer scope and configuration, and confirm the finding points to the declaration you changed.
  • A reflection or generator consumer makes the finding a false positive: Suppress only that finding and document the consumer; avoid disabling the rule globally.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.