Skip to content

Commit

Permalink
Enable CA1852: Seal internal types
Browse files Browse the repository at this point in the history
  • Loading branch information
ladipro committed Feb 3, 2023
1 parent 48300b9 commit ba932c1
Show file tree
Hide file tree
Showing 143 changed files with 233 additions and 230 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ csharp_space_between_square_brackets = false
dotnet_code_quality.ca1802.api_surface = private, internal
dotnet_code_quality.ca2208.api_surface = public

# CA1852: Seal internal types
dotnet_diagnostic.ca1852.severity = warning

# RS0037: Enable tracking of nullability of reference types in the declared API
# Our API is not annotated but new classes get nullable enabled so disable this.
# We'd be happy if everything was annotated and this could be removed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public ElementLinkPair<CT> QuerySingleChildrenWithValidation<CT>(Func<T, IEnumer
}
}

internal class ProjectXmlPair : ElementLinkPair<ProjectRootElement>
internal sealed class ProjectXmlPair : ElementLinkPair<ProjectRootElement>
{
private ProjectPair Project { get; }
public ProjectXmlPair(ProjectPair pair) : base(null, pair.View.Xml, pair.Real.Xml) { this.Project = pair; this.PRE = this; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public virtual void Verify()
}
}

internal class ValidationContext
internal sealed class ValidationContext
{
public ValidationContext() { }
public ValidationContext(ProjectPair pair) { this.Pair = pair; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
using Microsoft.Build.Framework;
using Xunit;

internal class ProjectPair : LinkPair<Project>
internal sealed class ProjectPair : LinkPair<Project>
{
public ProjectPair(Project view, Project real)
: base(view, real)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
using Microsoft.Build.Construction;
using Microsoft.Build.ObjectModelRemoting;

internal class MockProjectChooseElementLinkRemoter : MockProjectElementContainerLinkRemoter
internal sealed class MockProjectChooseElementLinkRemoter : MockProjectElementContainerLinkRemoter
{
public override ProjectElement ImportImpl(ProjectCollectionLinker remote)
{
Expand All @@ -23,7 +23,7 @@ public override ProjectElement CreateLinkedObject(IImportHolder holder)
}
}

internal class MockProjectChooseElementLink : ProjectChooseElementLink, ILinkMock, IProjectElementLinkHelper, IProjectElementContainerLinkHelper
internal sealed class MockProjectChooseElementLink : ProjectChooseElementLink, ILinkMock, IProjectElementLinkHelper, IProjectElementContainerLinkHelper
{
public MockProjectChooseElementLink(MockProjectChooseElementLinkRemoter proxy, IImportHolder holder)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void RemoveChild(MockProjectElementLinkRemoter child)
}

// not used - just a copy/paste template for remoting support objects of Construction model hierarchical containers.
internal class TemplateProjectElementContainerLink : ProjectElementContainerLink, ILinkMock, IProjectElementLinkHelper, IProjectElementContainerLinkHelper
internal sealed class TemplateProjectElementContainerLink : ProjectElementContainerLink, ILinkMock, IProjectElementLinkHelper, IProjectElementContainerLinkHelper
{
public TemplateProjectElementContainerLink(MockProjectElementContainerLinkRemoter proxy, IImportHolder holder)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void SetOrRemoveAttribute(string name, string value, bool clearAttributeC
}

// not used - just a copy/paste template for remoting support objects of Construction model hierarchical elements.
internal class TemplateProjectElementLink : ProjectElementLink, ILinkMock, IProjectElementLinkHelper
internal sealed class TemplateProjectElementLink : ProjectElementLink, ILinkMock, IProjectElementLinkHelper
{
public TemplateProjectElementLink(MockProjectElementLinkRemoter proxy, IImportHolder holder)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
using Microsoft.Build.Construction;
using Microsoft.Build.ObjectModelRemoting;

internal class MockProjectExtensionsElementLinkRemoter : MockProjectElementLinkRemoter
internal sealed class MockProjectExtensionsElementLinkRemoter : MockProjectElementLinkRemoter
{
public ProjectExtensionsElement ExtensionXml => (ProjectExtensionsElement)Source;

Expand All @@ -30,7 +30,7 @@ public override ProjectElement CreateLinkedObject(IImportHolder holder)
public void SetSubElement(string name, string value) { this.ExtensionXml[name] = value; }
}

internal class MockProjectExtensionsElementLink : ProjectExtensionsElementLink, ILinkMock, IProjectElementLinkHelper
internal sealed class MockProjectExtensionsElementLink : ProjectExtensionsElementLink, ILinkMock, IProjectElementLinkHelper
{
public MockProjectExtensionsElementLink(MockProjectExtensionsElementLinkRemoter proxy, IImportHolder holder)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
using Microsoft.Build.Construction;
using Microsoft.Build.ObjectModelRemoting;

internal class MockProjectImportElementLinkRemoter : MockProjectElementLinkRemoter
internal sealed class MockProjectImportElementLinkRemoter : MockProjectElementLinkRemoter
{
public ProjectImportElement ImportElementXml => (ProjectImportElement)Source;

Expand All @@ -28,7 +28,7 @@ public override ProjectElement CreateLinkedObject(IImportHolder holder)
public MockProjectElementLinkRemoter OriginalElement => this.Export(ImportElementXml.OriginalElement);
}

internal class MockProjectImportElementLink : ProjectImportElementLink, ILinkMock, IProjectElementLinkHelper
internal sealed class MockProjectImportElementLink : ProjectImportElementLink, ILinkMock, IProjectElementLinkHelper
{
public MockProjectImportElementLink(MockProjectImportElementLinkRemoter proxy, IImportHolder holder)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
using Microsoft.Build.Construction;
using Microsoft.Build.ObjectModelRemoting;

internal class MockProjectImportGroupElementLinkRemoter : MockProjectElementContainerLinkRemoter
internal sealed class MockProjectImportGroupElementLinkRemoter : MockProjectElementContainerLinkRemoter
{
public override ProjectElement ImportImpl(ProjectCollectionLinker remote)
{
Expand All @@ -23,7 +23,7 @@ public override ProjectElement CreateLinkedObject(IImportHolder holder)
}
}

internal class MockProjectImportGroupElementLink : ProjectImportGroupElementLink, ILinkMock, IProjectElementLinkHelper, IProjectElementContainerLinkHelper
internal sealed class MockProjectImportGroupElementLink : ProjectImportGroupElementLink, ILinkMock, IProjectElementLinkHelper, IProjectElementContainerLinkHelper
{
public MockProjectImportGroupElementLink(MockProjectImportGroupElementLinkRemoter proxy, IImportHolder holder)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
using Microsoft.Build.Construction;
using Microsoft.Build.ObjectModelRemoting;

internal class MockProjectItemDefinitionElementLinkRemoter : MockProjectElementContainerLinkRemoter
internal sealed class MockProjectItemDefinitionElementLinkRemoter : MockProjectElementContainerLinkRemoter
{
public override ProjectElement ImportImpl(ProjectCollectionLinker remote)
{
Expand All @@ -23,7 +23,7 @@ public override ProjectElement CreateLinkedObject(IImportHolder holder)
}
}

internal class MockProjectItemDefinitionElementLink : ProjectItemDefinitionElementLink, ILinkMock, IProjectElementLinkHelper, IProjectElementContainerLinkHelper
internal sealed class MockProjectItemDefinitionElementLink : ProjectItemDefinitionElementLink, ILinkMock, IProjectElementLinkHelper, IProjectElementContainerLinkHelper
{
public MockProjectItemDefinitionElementLink(MockProjectItemDefinitionElementLinkRemoter proxy, IImportHolder holder)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
using Microsoft.Build.Construction;
using Microsoft.Build.ObjectModelRemoting;

internal class MockProjectItemDefinitionGroupElementLinkRemoter : MockProjectElementContainerLinkRemoter
internal sealed class MockProjectItemDefinitionGroupElementLinkRemoter : MockProjectElementContainerLinkRemoter
{
public override ProjectElement ImportImpl(ProjectCollectionLinker remote)
{
Expand All @@ -23,7 +23,7 @@ public override ProjectElement CreateLinkedObject(IImportHolder holder)
}
}

internal class MockProjectItemDefinitionGroupElementLink : ProjectItemDefinitionGroupElementLink, ILinkMock, IProjectElementLinkHelper, IProjectElementContainerLinkHelper
internal sealed class MockProjectItemDefinitionGroupElementLink : ProjectItemDefinitionGroupElementLink, ILinkMock, IProjectElementLinkHelper, IProjectElementContainerLinkHelper
{
public MockProjectItemDefinitionGroupElementLink(MockProjectItemDefinitionGroupElementLinkRemoter proxy, IImportHolder holder)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
using Microsoft.Build.Construction;
using Microsoft.Build.ObjectModelRemoting;

internal class MockProjectItemElementLinkRemoter : MockProjectElementContainerLinkRemoter
internal sealed class MockProjectItemElementLinkRemoter : MockProjectElementContainerLinkRemoter
{
public ProjectItemElement ItemXml => (ProjectItemElement)Source;

Expand All @@ -30,7 +30,7 @@ public void ChangeItemType(string newType)
}
}

internal class MockProjectItemElementLink : ProjectItemElementLink, ILinkMock, IProjectElementLinkHelper, IProjectElementContainerLinkHelper
internal sealed class MockProjectItemElementLink : ProjectItemElementLink, ILinkMock, IProjectElementLinkHelper, IProjectElementContainerLinkHelper
{
public MockProjectItemElementLink(MockProjectItemElementLinkRemoter proxy, IImportHolder holder)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
using Microsoft.Build.Construction;
using Microsoft.Build.ObjectModelRemoting;

internal class MockProjectItemGroupElementLinkRemoter : MockProjectElementContainerLinkRemoter
internal sealed class MockProjectItemGroupElementLinkRemoter : MockProjectElementContainerLinkRemoter
{
public override ProjectElement ImportImpl(ProjectCollectionLinker remote)
{
Expand All @@ -23,7 +23,7 @@ public override ProjectElement CreateLinkedObject(IImportHolder holder)
}
}

internal class MockProjectItemGroupElementLink : ProjectItemGroupElementLink, ILinkMock, IProjectElementLinkHelper, IProjectElementContainerLinkHelper
internal sealed class MockProjectItemGroupElementLink : ProjectItemGroupElementLink, ILinkMock, IProjectElementLinkHelper, IProjectElementContainerLinkHelper
{
public MockProjectItemGroupElementLink(MockProjectItemGroupElementLinkRemoter proxy, IImportHolder holder)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
using Microsoft.Build.Construction;
using Microsoft.Build.ObjectModelRemoting;

internal class MockProjectMetadataElementLinkRemoter : MockProjectElementLinkRemoter
internal sealed class MockProjectMetadataElementLinkRemoter : MockProjectElementLinkRemoter
{
public ProjectMetadataElement MetadataXml => (ProjectMetadataElement)Source;

Expand All @@ -29,7 +29,7 @@ public override ProjectElement CreateLinkedObject(IImportHolder holder)
public void ChangeName(string newName) { MetadataXml.Name = newName; }
}

internal class MockProjectMetadataElementLink : ProjectMetadataElementLink, ILinkMock, IProjectElementLinkHelper
internal sealed class MockProjectMetadataElementLink : ProjectMetadataElementLink, ILinkMock, IProjectElementLinkHelper
{
public MockProjectMetadataElementLink(MockProjectMetadataElementLinkRemoter proxy, IImportHolder holder)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
using Microsoft.Build.Construction;
using Microsoft.Build.ObjectModelRemoting;

internal class MockProjectOnErrorElementLinkRemoter : MockProjectElementLinkRemoter
internal sealed class MockProjectOnErrorElementLinkRemoter : MockProjectElementLinkRemoter
{
public override ProjectElement ImportImpl(ProjectCollectionLinker remote)
{
Expand All @@ -23,7 +23,7 @@ public override ProjectElement CreateLinkedObject(IImportHolder holder)
}
}

internal class MockProjectOnErrorElementLink : ProjectOnErrorElementLink, ILinkMock, IProjectElementLinkHelper
internal sealed class MockProjectOnErrorElementLink : ProjectOnErrorElementLink, ILinkMock, IProjectElementLinkHelper
{
public MockProjectOnErrorElementLink(MockProjectOnErrorElementLinkRemoter proxy, IImportHolder holder)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
using Microsoft.Build.Construction;
using Microsoft.Build.ObjectModelRemoting;

internal class MockProjectOtherwiseElementLinkRemoter : MockProjectElementContainerLinkRemoter
internal sealed class MockProjectOtherwiseElementLinkRemoter : MockProjectElementContainerLinkRemoter
{
public override ProjectElement ImportImpl(ProjectCollectionLinker remote)
{
Expand All @@ -23,7 +23,7 @@ public override ProjectElement CreateLinkedObject(IImportHolder holder)
}
}

internal class MockProjectOtherwiseElementLink : ProjectOtherwiseElementLink, ILinkMock, IProjectElementLinkHelper, IProjectElementContainerLinkHelper
internal sealed class MockProjectOtherwiseElementLink : ProjectOtherwiseElementLink, ILinkMock, IProjectElementLinkHelper, IProjectElementContainerLinkHelper
{
public MockProjectOtherwiseElementLink(MockProjectOtherwiseElementLinkRemoter proxy, IImportHolder holder)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
using Microsoft.Build.Construction;
using Microsoft.Build.ObjectModelRemoting;

internal class MockProjectOutputElementLinkRemoter : MockProjectElementLinkRemoter
internal sealed class MockProjectOutputElementLinkRemoter : MockProjectElementLinkRemoter
{
public override ProjectElement ImportImpl(ProjectCollectionLinker remote)
{
Expand All @@ -23,7 +23,7 @@ public override ProjectElement CreateLinkedObject(IImportHolder holder)
}
}

internal class MockProjectOutputElementLink : ProjectOutputElementLink, ILinkMock, IProjectElementLinkHelper
internal sealed class MockProjectOutputElementLink : ProjectOutputElementLink, ILinkMock, IProjectElementLinkHelper
{
public MockProjectOutputElementLink(MockProjectOutputElementLinkRemoter proxy, IImportHolder holder)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
using Microsoft.Build.Construction;
using Microsoft.Build.ObjectModelRemoting;

internal class MockProjectPropertyElementLinkRemoter : MockProjectElementLinkRemoter
internal sealed class MockProjectPropertyElementLinkRemoter : MockProjectElementLinkRemoter
{
public ProjectPropertyElement PropertyXml => (ProjectPropertyElement)Source;

Expand All @@ -29,7 +29,7 @@ public override ProjectElement CreateLinkedObject(IImportHolder holder)
public void ChangeName(string newName) { PropertyXml.Name = newName; }
}

internal class MockProjectPropertyElementLink : ProjectPropertyElementLink, ILinkMock, IProjectElementLinkHelper
internal sealed class MockProjectPropertyElementLink : ProjectPropertyElementLink, ILinkMock, IProjectElementLinkHelper
{
public MockProjectPropertyElementLink(MockProjectPropertyElementLinkRemoter proxy, IImportHolder holder)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
using Microsoft.Build.Construction;
using Microsoft.Build.ObjectModelRemoting;

internal class MockProjectPropertyGroupElementLinkRemoter : MockProjectElementContainerLinkRemoter
internal sealed class MockProjectPropertyGroupElementLinkRemoter : MockProjectElementContainerLinkRemoter
{
public override ProjectElement ImportImpl(ProjectCollectionLinker remote)
{
Expand All @@ -23,7 +23,7 @@ public override ProjectElement CreateLinkedObject(IImportHolder holder)
}
}

internal class MockProjectPropertyGroupElementLink : ProjectPropertyGroupElementLink, ILinkMock, IProjectElementLinkHelper, IProjectElementContainerLinkHelper
internal sealed class MockProjectPropertyGroupElementLink : ProjectPropertyGroupElementLink, ILinkMock, IProjectElementLinkHelper, IProjectElementContainerLinkHelper
{
public MockProjectPropertyGroupElementLink(MockProjectPropertyGroupElementLinkRemoter proxy, IImportHolder holder)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
using Microsoft.Build.Construction;
using Microsoft.Build.ObjectModelRemoting;

internal class MockProjectRootElementLinkRemoter : MockProjectElementContainerLinkRemoter
internal sealed class MockProjectRootElementLinkRemoter : MockProjectElementContainerLinkRemoter
{
private ProjectRootElement ProjectXml => (ProjectRootElement)Source;

Expand Down Expand Up @@ -146,7 +146,7 @@ public MockProjectSdkElementLinkRemoter CreateProjectSdkElement(string sdkName,
}


internal class MockProjectRootElementLink : ProjectRootElementLink, ILinkMock, IProjectElementLinkHelper, IProjectElementContainerLinkHelper
internal sealed class MockProjectRootElementLink : ProjectRootElementLink, ILinkMock, IProjectElementLinkHelper, IProjectElementContainerLinkHelper
{
public MockProjectRootElementLink(MockProjectRootElementLinkRemoter proxy, IImportHolder holder)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
using Microsoft.Build.Construction;
using Microsoft.Build.ObjectModelRemoting;

internal class MockProjectSdkElementLinkRemoter : MockProjectElementContainerLinkRemoter
internal sealed class MockProjectSdkElementLinkRemoter : MockProjectElementContainerLinkRemoter
{
public override ProjectElement ImportImpl(ProjectCollectionLinker remote)
{
Expand All @@ -23,7 +23,7 @@ public override ProjectElement CreateLinkedObject(IImportHolder holder)
}
}

internal class MockProjectSdkElementLink : ProjectSdkElementLink, ILinkMock, IProjectElementLinkHelper, IProjectElementContainerLinkHelper
internal sealed class MockProjectSdkElementLink : ProjectSdkElementLink, ILinkMock, IProjectElementLinkHelper, IProjectElementContainerLinkHelper
{
public MockProjectSdkElementLink(MockProjectSdkElementLinkRemoter proxy, IImportHolder holder)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
using Microsoft.Build.Construction;
using Microsoft.Build.ObjectModelRemoting;

internal class MockProjectTargetElementLinkRemoter : MockProjectElementContainerLinkRemoter
internal sealed class MockProjectTargetElementLinkRemoter : MockProjectElementContainerLinkRemoter
{
public ProjectTargetElement TargetXml => (ProjectTargetElement)Source;

Expand All @@ -29,7 +29,7 @@ public override ProjectElement CreateLinkedObject(IImportHolder holder)
public string Returns { set => this.TargetXml.Returns = value; }
}

internal class MockProjectTargetElementLink : ProjectTargetElementLink, ILinkMock, IProjectElementLinkHelper, IProjectElementContainerLinkHelper
internal sealed class MockProjectTargetElementLink : ProjectTargetElementLink, ILinkMock, IProjectElementLinkHelper, IProjectElementContainerLinkHelper
{
public MockProjectTargetElementLink(MockProjectTargetElementLinkRemoter proxy, IImportHolder holder)
{
Expand Down
Loading

0 comments on commit ba932c1

Please sign in to comment.