Skip to content

Commit 60643e2

Browse files
authored
Enable CA1012: Abstract types should not have public constructors (#13940)
https://docs.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1012
1 parent eafeab5 commit 60643e2

File tree

7 files changed

+9
-8
lines changed

7 files changed

+9
-8
lines changed

.globalconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ dotnet_diagnostic.CA1008.severity = none
2424
dotnet_diagnostic.CA1010.severity = silent
2525

2626
# CA1012: Abstract types should not have public constructors
27-
dotnet_diagnostic.CA1012.severity = none
27+
dotnet_diagnostic.CA1012.severity = warning
28+
dotnet_code_quality.ca1012.api_surface = all
2829

2930
# CA1014: Mark assemblies with CLSCompliant
3031
dotnet_diagnostic.CA1014.severity = none

src/Microsoft.Management.Infrastructure.CimCmdlets/CimAsyncOperation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ internal abstract class CimAsyncOperation : IDisposable
2828
/// <summary>
2929
/// The constructor.
3030
/// </summary>
31-
public CimAsyncOperation()
31+
protected CimAsyncOperation()
3232
{
3333
this.moreActionEvent = new ManualResetEventSlim(false);
3434
this.actionQueue = new ConcurrentQueue<CimBaseAction>();

src/Microsoft.Management.Infrastructure.CimCmdlets/CimBaseAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal abstract class CimBaseAction
1919
/// <summary>
2020
/// Constructor method.
2121
/// </summary>
22-
public CimBaseAction()
22+
protected CimBaseAction()
2323
{
2424
}
2525

src/Microsoft.Management.Infrastructure.CimCmdlets/CimResultObserver.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ internal abstract class AsyncResultEventArgsBase : EventArgs
6969
/// <param name="session"></param>
7070
/// <param name="observable"></param>
7171
/// <param name="resultType"></param>
72-
public AsyncResultEventArgsBase(
72+
protected AsyncResultEventArgsBase(
7373
CimSession session,
7474
IObservable<object> observable,
7575
AsyncResultType resultType)
@@ -86,7 +86,7 @@ public AsyncResultEventArgsBase(
8686
/// <param name="observable"></param>
8787
/// <param name="resultType"></param>
8888
/// <param name="context"></param>
89-
public AsyncResultEventArgsBase(
89+
protected AsyncResultEventArgsBase(
9090
CimSession session,
9191
IObservable<object> observable,
9292
AsyncResultType resultType,

src/System.Management.Automation/engine/debugger/debugger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4198,7 +4198,7 @@ public Guid ParentDebuggerId
41984198
/// <param name="runspace">Runspace.</param>
41994199
/// <param name="runspaceType">Runspace type.</param>
42004200
/// <param name="parentDebuggerId">Debugger Id of parent.</param>
4201-
public NestedRunspaceDebugger(
4201+
protected NestedRunspaceDebugger(
42024202
Runspace runspace,
42034203
PSMonitorRunspaceType runspaceType,
42044204
Guid parentDebuggerId)

src/System.Management.Automation/engine/interpreter/ControlFlowInstructions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ internal abstract class IndexedBranchInstruction : Instruction
204204

205205
internal readonly int _labelIndex;
206206

207-
public IndexedBranchInstruction(int labelIndex)
207+
protected IndexedBranchInstruction(int labelIndex)
208208
{
209209
_labelIndex = labelIndex;
210210
}

src/System.Management.Automation/utils/ObjectReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ internal abstract class ObjectReaderBase<T> : PipelineReader<T>, IDisposable
2121
/// </summary>
2222
/// <param name="stream">The stream to read.</param>
2323
/// <exception cref="ArgumentNullException">Thrown if the specified stream is null.</exception>
24-
public ObjectReaderBase([In, Out] ObjectStreamBase stream)
24+
protected ObjectReaderBase([In, Out] ObjectStreamBase stream)
2525
{
2626
if (stream == null)
2727
{

0 commit comments

Comments
 (0)