1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
3
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
4
// software and associated documentation files (the "Software"), to deal in the Software
5
// without restriction, including without limitation the rights to use, copy, modify, merge,
6
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7
// to whom the Software is furnished to do so, subject to the following conditions:
9
// The above copyright notice and this permission notice shall be included in all copies or
10
// substantial portions of the Software.
12
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17
// DEALINGS IN THE SOFTWARE.
20
using System.Collections.Generic;
21
using System.Diagnostics.Contracts;
23
using ICSharpCode.NRefactory.Semantics;
25
namespace ICSharpCode.NRefactory.TypeSystem
28
/// Represents an unresolved attribute.
31
[ContractClass(typeof(IUnresolvedAttributeContract))]
33
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
34
public interface IUnresolvedAttribute
37
/// Gets the code region of this attribute.
39
DomRegion Region { get; }
41
//ITypeReference AttributeType { get; }
44
/// Resolves the attribute.
46
IAttribute CreateResolvedAttribute(ITypeResolveContext context);
50
/// Represents an attribute.
53
[ContractClass(typeof(IAttributeContract))]
55
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
56
public interface IAttribute
59
/// Gets the code region of this attribute.
61
DomRegion Region { get; }
64
/// Gets the type of the attribute.
66
IType AttributeType { get; }
69
/// Gets the constructor being used.
70
/// This property may return null if no matching constructor was found.
72
IMethod Constructor { get; }
75
/// Gets the positional arguments.
77
IList<ResolveResult> PositionalArguments { get; }
80
/// Gets the named arguments passed to the attribute.
82
IList<KeyValuePair<IMember, ResolveResult>> NamedArguments { get; }
86
[ContractClassFor(typeof(IAttribute))]
87
abstract class IAttributeContract : IFreezableContract, IAttribute
89
DomRegion IAttribute.Region {
90
get { return DomRegion.Empty; }
93
ITypeReference IAttribute.AttributeType {
95
Contract.Ensures(Contract.Result<ITypeReference>() != null);
100
IList<IConstantValue> IAttribute.GetPositionalArguments(ITypeResolveContext context)
102
Contract.Requires(context != null);
103
Contract.Ensures(Contract.Result<IList<IConstantValue>>() != null);
107
IList<KeyValuePair<string, IConstantValue>> IAttribute.GetNamedArguments(ITypeResolveContext context)
109
Contract.Requires(context != null);
110
Contract.Ensures(Contract.Result<IList<KeyValuePair<string, IConstantValue>>>() != null);
114
IMethod IAttribute.ResolveConstructor(ITypeResolveContext context)
116
Contract.Requires(context != null);