Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Making ctors internal for types with internal abstract methods (#37479)
Browse files Browse the repository at this point in the history
* making ctors internal for types with internal abstract methods

* fixing build error
  • Loading branch information
Anipik authored and ericstj committed May 7, 2019
1 parent 5566506 commit 28a926b
Show file tree
Hide file tree
Showing 17 changed files with 225 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/System.Data.Common/ref/System.Data.Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public enum ConnectionState
[System.ComponentModel.DefaultPropertyAttribute("ConstraintName")]
public abstract partial class Constraint
{
protected Constraint() { }
internal Constraint() { }
[System.ComponentModel.DefaultValueAttribute("")]
public virtual string ConstraintName { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
Expand Down
2 changes: 2 additions & 0 deletions src/System.Data.Common/src/System/Data/Constraint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public abstract class Constraint
internal string _name = string.Empty;
internal PropertyCollection _extendedProperties = null;

internal Constraint() {}

/// <summary>
/// The name of this constraint within the <see cref='System.Data.ConstraintCollection'/>.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace System.Diagnostics.Tracing
{
public abstract partial class DiagnosticCounter : System.IDisposable
{
public DiagnosticCounter(string name, System.Diagnostics.Tracing.EventSource eventSource) { }
internal DiagnosticCounter(string name, System.Diagnostics.Tracing.EventSource eventSource) { }
public void AddMetadata(string key, string value) { }
public void Dispose() { }
public string DisplayName { get { throw null; } set { } }
Expand Down
4 changes: 2 additions & 2 deletions src/System.Linq.Queryable/ref/System.Linq.Queryable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ namespace System.Linq
{
public abstract partial class EnumerableExecutor
{
protected EnumerableExecutor() { }
internal EnumerableExecutor() { }
}
public partial class EnumerableExecutor<T> : System.Linq.EnumerableExecutor
{
public EnumerableExecutor(System.Linq.Expressions.Expression expression) { }
}
public abstract partial class EnumerableQuery
{
protected EnumerableQuery() { }
internal EnumerableQuery() { }
}
public partial class EnumerableQuery<T> : System.Linq.EnumerableQuery, System.Collections.Generic.IEnumerable<T>, System.Collections.IEnumerable, System.Linq.IOrderedQueryable, System.Linq.IOrderedQueryable<T>, System.Linq.IQueryable, System.Linq.IQueryable<T>, System.Linq.IQueryProvider
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public abstract class EnumerableExecutor
{
internal abstract object ExecuteBoxed();

internal EnumerableExecutor() { }

internal static EnumerableExecutor Create(Expression expression)
{
Type execType = typeof(EnumerableExecutor<>).MakeGenericType(expression.Type);
Expand Down
3 changes: 3 additions & 0 deletions src/System.Linq.Queryable/src/System/Linq/EnumerableQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public abstract class EnumerableQuery
{
internal abstract Expression Expression { get; }
internal abstract IEnumerable Enumerable { get; }

internal EnumerableQuery() {}

internal static IQueryable Create(Type elementType, IEnumerable sequence)
{
Type seqType = typeof(EnumerableQuery<>).MakeGenericType(elementType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public abstract class XmlSchemaDatatype

public virtual XmlSchemaDatatypeVariety Variety { get { return XmlSchemaDatatypeVariety.Atomic; } }

internal XmlSchemaDatatype() {}

public virtual object ChangeType(object value, Type targetType)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ namespace System.Xml.Schema

public abstract class XmlSchemaGroupBase : XmlSchemaParticle
{
internal XmlSchemaGroupBase() {}

[XmlIgnore]
public abstract XmlSchemaObjectCollection Items { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ void System.Collections.ICollection.CopyTo(System.Array array, int index) { }
}
public abstract partial class GenericSecurityDescriptor
{
protected GenericSecurityDescriptor() { }
internal GenericSecurityDescriptor() { }
public int BinaryLength { get { throw null; } }
public abstract System.Security.AccessControl.ControlFlags ControlFlags { get; }
public abstract System.Security.Principal.SecurityIdentifier Group { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ internal static int UnmarshalInt(byte[] binaryForm, int offset)

#region Constructors

protected GenericSecurityDescriptor()
internal GenericSecurityDescriptor()
{ }

#endregion
Expand Down
4 changes: 2 additions & 2 deletions src/System.Xml.ReaderWriter/ref/System.Xml.ReaderWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1726,7 +1726,7 @@ public enum XmlSchemaContentType
}
public abstract partial class XmlSchemaDatatype
{
protected XmlSchemaDatatype() { }
internal XmlSchemaDatatype() { }
public abstract System.Xml.XmlTokenizedType TokenizedType { get; }
public virtual System.Xml.Schema.XmlTypeCode TypeCode { get { throw null; } }
public abstract System.Type ValueType { get; }
Expand Down Expand Up @@ -1891,7 +1891,7 @@ public XmlSchemaGroup() { }
}
public abstract partial class XmlSchemaGroupBase : System.Xml.Schema.XmlSchemaParticle
{
protected XmlSchemaGroupBase() { }
internal XmlSchemaGroupBase() { }
[System.Xml.Serialization.XmlIgnoreAttribute]
public abstract System.Xml.Schema.XmlSchemaObjectCollection Items { get; }
}
Expand Down
37 changes: 36 additions & 1 deletion src/shims/ApiCompatBaseline.netcoreapp.netstandard.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,39 @@ CannotMakeMemberNonVirtual : Member 'System.ComponentModel.BaseNumberConverter.C
CannotMakeMemberNonVirtual : Member 'System.ComponentModel.BaseNumberConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext, System.Type)' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.ComponentModel.BaseNumberConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext, System.Globalization.CultureInfo, System.Object)' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.ComponentModel.BaseNumberConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext, System.Globalization.CultureInfo, System.Object, System.Type)' is non-virtual in the implementation but is virtual in the contract.
Total Issues: 27
Compat issues with assembly System.Xml.Schema:
CannotSealType : Type 'System.Xml.Schema.XmlSchemaDatatype' is effectively (has a private constructor) sealed in the implementation but not sealed in the contract.
MembersMustExist : Member 'System.Xml.Schema.XmlSchemaDatatype..ctor()' does not exist in the implementation but it does exist in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaDatatype.TokenizedType' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaDatatype.TypeCode' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaDatatype.ValueType' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaDatatype.Variety' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaDatatype.ChangeType(System.Object, System.Type)' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaDatatype.ChangeType(System.Object, System.Type, System.Xml.IXmlNamespaceResolver)' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaDatatype.IsDerivedFrom(System.Xml.Schema.XmlSchemaDatatype)' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaDatatype.ParseValue(System.String, System.Xml.XmlNameTable, System.Xml.IXmlNamespaceResolver)' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaDatatype.TokenizedType.get()' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaDatatype.TypeCode.get()' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaDatatype.ValueType.get()' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaDatatype.Variety.get()' is non-virtual in the implementation but is virtual in the contract.
Compat issues with assembly System.Xml.ReaderWriter:
CannotSealType : Type 'System.Xml.Schema.XmlSchemaGroupBase' is effectively (has a private constructor) sealed in the implementation but not sealed in the contract.
MembersMustExist : Member 'System.Xml.Schema.XmlSchemaGroupBase..ctor()' does not exist in the implementation but it does exist in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaGroupBase.Items' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaGroupBase.Items.get()' is non-virtual in the implementation but is virtual in the contract.
Compat issues with assembly System.Data.Constraint:
CannotSealType : Type 'System.Data.Constraint' is effectively (has a private constructor) sealed in the implementation but not sealed in the contract.
MembersMustExist : Member 'System.Data.Constraint..ctor()' does not exist in the implementation but it does exist in the contract.
CannotMakeMemberNonVirtual : Member 'System.Data.Constraint.ConstraintName' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Data.Constraint.Table' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Data.Constraint._DataSet' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Data.Constraint.ConstraintName.get()' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Data.Constraint.ConstraintName.set(System.String)' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Data.Constraint.Table.get()' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Data.Constraint.ToString()' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Data.Constraint._DataSet.get()' is non-virtual in the implementation but is virtual in the contract.
CannotSealType : Type 'System.Linq.EnumerableExecutor' is effectively (has a private constructor) sealed in the implementation but not sealed in the contract.
MembersMustExist : Member 'System.Linq.EnumerableExecutor..ctor()' does not exist in the implementation but it does exist in the contract.
CannotSealType : Type 'System.Linq.EnumerableQuery' is effectively (has a private constructor) sealed in the implementation but not sealed in the contract.
MembersMustExist : Member 'System.Linq.EnumerableQuery..ctor()' does not exist in the implementation but it does exist in the contract.
Total Issues: 59
34 changes: 33 additions & 1 deletion src/shims/ApiCompatBaseline.netcoreapp.netstandardOnly.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,36 @@ CannotMakeMemberNonVirtual : Member 'System.ComponentModel.BaseNumberConverter.C
CannotMakeMemberNonVirtual : Member 'System.ComponentModel.BaseNumberConverter.CanConvertTo(System.ComponentModel.ITypeDescriptorContext, System.Type)' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.ComponentModel.BaseNumberConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext, System.Globalization.CultureInfo, System.Object)' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.ComponentModel.BaseNumberConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext, System.Globalization.CultureInfo, System.Object, System.Type)' is non-virtual in the implementation but is virtual in the contract.
Total Issues: 86
CannotSealType : Type 'System.Xml.Schema.XmlSchemaDatatype' is effectively (has a private constructor) sealed in the implementation but not sealed in the contract.
MembersMustExist : Member 'System.Xml.Schema.XmlSchemaDatatype..ctor()' does not exist in the implementation but it does exist in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaDatatype.TokenizedType' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaDatatype.TypeCode' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaDatatype.ValueType' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaDatatype.Variety' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaDatatype.ChangeType(System.Object, System.Type)' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaDatatype.ChangeType(System.Object, System.Type, System.Xml.IXmlNamespaceResolver)' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaDatatype.IsDerivedFrom(System.Xml.Schema.XmlSchemaDatatype)' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaDatatype.ParseValue(System.String, System.Xml.XmlNameTable, System.Xml.IXmlNamespaceResolver)' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaDatatype.TokenizedType.get()' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaDatatype.TypeCode.get()' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaDatatype.ValueType.get()' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaDatatype.Variety.get()' is non-virtual in the implementation but is virtual in the contract.
CannotSealType : Type 'System.Xml.Schema.XmlSchemaGroupBase' is effectively (has a private constructor) sealed in the implementation but not sealed in the contract.
MembersMustExist : Member 'System.Xml.Schema.XmlSchemaGroupBase..ctor()' does not exist in the implementation but it does exist in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaGroupBase.Items' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Xml.Schema.XmlSchemaGroupBase.Items.get()' is non-virtual in the implementation but is virtual in the contract.
CannotSealType : Type 'System.Data.Constraint' is effectively (has a private constructor) sealed in the implementation but not sealed in the contract.
MembersMustExist : Member 'System.Data.Constraint..ctor()' does not exist in the implementation but it does exist in the contract.
CannotMakeMemberNonVirtual : Member 'System.Data.Constraint.ConstraintName' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Data.Constraint.Table' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Data.Constraint._DataSet' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Data.Constraint.ConstraintName.get()' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Data.Constraint.ConstraintName.set(System.String)' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Data.Constraint.Table.get()' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Data.Constraint.ToString()' is non-virtual in the implementation but is virtual in the contract.
CannotMakeMemberNonVirtual : Member 'System.Data.Constraint._DataSet.get()' is non-virtual in the implementation but is virtual in the contract.
CannotSealType : Type 'System.Linq.EnumerableExecutor' is effectively (has a private constructor) sealed in the implementation but not sealed in the contract.
MembersMustExist : Member 'System.Linq.EnumerableExecutor..ctor()' does not exist in the implementation but it does exist in the contract.
CannotSealType : Type 'System.Linq.EnumerableQuery' is effectively (has a private constructor) sealed in the implementation but not sealed in the contract.
MembersMustExist : Member 'System.Linq.EnumerableQuery..ctor()' does not exist in the implementation but it does exist in the contract.
Total Issues: 118
Loading

0 comments on commit 28a926b

Please sign in to comment.