Browse Source

Remove outdated code contracts.

newNRvisualizers
Daniel Grunwald 14 years ago
parent
commit
fb4436499e
  1. 45
      ICSharpCode.NRefactory/TypeSystem/IAttribute.cs
  2. 20
      ICSharpCode.NRefactory/TypeSystem/IFreezable.cs
  3. 22
      ICSharpCode.NRefactory/TypeSystem/IInterningProvider.cs
  4. 26
      ICSharpCode.NRefactory/TypeSystem/ISupportsInterning.cs
  5. 18
      ICSharpCode.NRefactory/TypeSystem/ITypeReference.cs
  6. 36
      ICSharpCode.NRefactory/TypeSystem/IVariable.cs

45
ICSharpCode.NRefactory/TypeSystem/IAttribute.cs

@ -26,9 +26,6 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -26,9 +26,6 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// <summary>
/// Represents an unresolved attribute.
/// </summary>
#if WITH_CONTRACTS
[ContractClass(typeof(IUnresolvedAttributeContract))]
#endif
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
public interface IUnresolvedAttribute
{
@ -37,8 +34,6 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -37,8 +34,6 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
DomRegion Region { get; }
//ITypeReference AttributeType { get; }
/// <summary>
/// Resolves the attribute.
/// </summary>
@ -48,9 +43,6 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -48,9 +43,6 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// <summary>
/// Represents an attribute.
/// </summary>
#if WITH_CONTRACTS
[ContractClass(typeof(IAttributeContract))]
#endif
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
public interface IAttribute
{
@ -80,41 +72,4 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -80,41 +72,4 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
IList<KeyValuePair<IMember, ResolveResult>> NamedArguments { get; }
}
#if WITH_CONTRACTS
[ContractClassFor(typeof(IAttribute))]
abstract class IAttributeContract : IFreezableContract, IAttribute
{
DomRegion IAttribute.Region {
get { return DomRegion.Empty; }
}
ITypeReference IAttribute.AttributeType {
get {
Contract.Ensures(Contract.Result<ITypeReference>() != null);
return null;
}
}
IList<IConstantValue> IAttribute.GetPositionalArguments(ITypeResolveContext context)
{
Contract.Requires(context != null);
Contract.Ensures(Contract.Result<IList<IConstantValue>>() != null);
return null;
}
IList<KeyValuePair<string, IConstantValue>> IAttribute.GetNamedArguments(ITypeResolveContext context)
{
Contract.Requires(context != null);
Contract.Ensures(Contract.Result<IList<KeyValuePair<string, IConstantValue>>>() != null);
return null;
}
IMethod IAttribute.ResolveConstructor(ITypeResolveContext context)
{
Contract.Requires(context != null);
return null;
}
}
#endif
}

20
ICSharpCode.NRefactory/TypeSystem/IFreezable.cs

@ -17,13 +17,9 @@ @@ -17,13 +17,9 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Diagnostics.Contracts;
namespace ICSharpCode.NRefactory.TypeSystem
{
#if WITH_CONTRACTS
[ContractClass(typeof(IFreezableContract))]
#endif
public interface IFreezable
{
/// <summary>
@ -36,20 +32,4 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -36,20 +32,4 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
void Freeze();
}
#if WITH_CONTRACTS
[ContractClassFor(typeof(IFreezable))]
abstract class IFreezableContract : IFreezable
{
bool IFreezable.IsFrozen {
get { return default(bool); }
}
void IFreezable.Freeze()
{
IFreezable self = this;
Contract.Ensures(self.IsFrozen);
}
}
#endif
}

22
ICSharpCode.NRefactory/TypeSystem/IInterningProvider.cs

@ -18,7 +18,6 @@ @@ -18,7 +18,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace ICSharpCode.NRefactory.TypeSystem
{
@ -40,9 +39,6 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -40,9 +39,6 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// and which are used only within a single type definition. Then a persistent file format could be organized so
/// that shared objects are loaded only once, yet non-shared objects get loaded lazily together with the class.
/// </remarks>
#if WITH_CONTRACTS
[ContractClass(typeof(IInterningProviderContract))]
#endif
public interface IInterningProvider
{
/// <summary>
@ -55,22 +51,4 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -55,22 +51,4 @@ namespace ICSharpCode.NRefactory.TypeSystem
IList<T> InternList<T>(IList<T> list) where T : class;
}
#if WITH_CONTRACTS
[ContractClassFor(typeof(IInterningProvider))]
abstract class IInterningProviderContract : IInterningProvider
{
T IInterningProvider.Intern<T>(T obj)
{
Contract.Ensures((Contract.Result<T>() == null) == (obj == null));
return obj;
}
IList<T> IInterningProvider.InternList<T>(IList<T> list)
{
Contract.Ensures((Contract.Result<IList<T>>() == null) == (list == null));
return list;
}
}
#endif
}

26
ICSharpCode.NRefactory/TypeSystem/ISupportsInterning.cs

@ -17,8 +17,6 @@ @@ -17,8 +17,6 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace ICSharpCode.NRefactory.TypeSystem
{
@ -26,9 +24,6 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -26,9 +24,6 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// Interface for TypeSystem objects that support interning.
/// See <see cref="IInterningProvider"/> for more information.
/// </summary>
#if WITH_CONTRACTS
[ContractClass(typeof(ISupportsInterningContract))]
#endif
public interface ISupportsInterning
{
/// <summary>
@ -46,25 +41,4 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -46,25 +41,4 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
bool EqualsForInterning(ISupportsInterning other);
}
#if WITH_CONTRACTS
[ContractClassFor(typeof(ISupportsInterning))]
abstract class ISupportsInterningContract : ISupportsInterning
{
void ISupportsInterning.PrepareForInterning(IInterningProvider provider)
{
Contract.Requires(provider != null);
}
int ISupportsInterning.GetHashCodeForInterning()
{
return 0;
}
bool ISupportsInterning.EqualsForInterning(ISupportsInterning other)
{
return false;
}
}
#endif
}

18
ICSharpCode.NRefactory/TypeSystem/ITypeReference.cs

@ -17,8 +17,6 @@ @@ -17,8 +17,6 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace ICSharpCode.NRefactory.TypeSystem
{
@ -26,9 +24,6 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -26,9 +24,6 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// Represents a reference to a type.
/// Must be resolved before it can be used as type.
/// </summary>
#if WITH_CONTRACTS
[ContractClass(typeof(ITypeReferenceContract))]
#endif
public interface ITypeReference
{
// Keep this interface simple: I decided against having GetMethods/GetEvents etc. here,
@ -81,17 +76,4 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -81,17 +76,4 @@ namespace ICSharpCode.NRefactory.TypeSystem
ITypeResolveContext WithCurrentTypeDefinition(ITypeDefinition typeDefinition);
ITypeResolveContext WithCurrentMember(IMember member);
}
#if WITH_CONTRACTS
[ContractClassFor(typeof(ITypeReference))]
abstract class ITypeReferenceContract : ITypeReference
{
IType ITypeReference.Resolve(ITypeResolveContext context)
{
Contract.Requires(context != null);
Contract.Ensures(Contract.Result<IType>() != null);
return null;
}
}
#endif
}

36
ICSharpCode.NRefactory/TypeSystem/IVariable.cs

@ -17,16 +17,12 @@ @@ -17,16 +17,12 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Diagnostics.Contracts;
namespace ICSharpCode.NRefactory.TypeSystem
{
/// <summary>
/// Represents a variable (name/type pair).
/// </summary>
#if WITH_CONTRACTS
[ContractClass(typeof(IVariableContract))]
#endif
public interface IVariable
{
/// <summary>
@ -55,36 +51,4 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -55,36 +51,4 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
object ConstantValue { get; }
}
#if WITH_CONTRACTS
[ContractClassFor(typeof(IVariable))]
abstract class IVariableContract : IVariable
{
string IVariable.Name {
get {
Contract.Ensures(Contract.Result<string>() != null);
return null;
}
}
ITypeReference IVariable.Type {
get {
Contract.Ensures(Contract.Result<ITypeReference>() != null);
return null;
}
}
bool IVariable.IsConst {
get {
IVariable @this = this;
Contract.Ensures(Contract.Result<bool>() == (@this.ConstantValue != null));
return false;
}
}
object IVariable.ConstantValue {
get { return null; }
}
}
#endif
}

Loading…
Cancel
Save