Port NRefactory to .NET 3.5.
This commit is contained in:
Родитель
3b6fe6ff0d
Коммит
41b4385d7c
|
@ -11,6 +11,7 @@
|
|||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<ProductVersion>10.0.0</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<AssemblyName>ICSharpCode.NRefactory.VB</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
|
|
|
@ -77,7 +77,7 @@ namespace ICSharpCode.NRefactory.CSharp
|
|||
b.Append(this.MemberName);
|
||||
if (this.TypeArguments.Any()) {
|
||||
b.Append('<');
|
||||
b.Append(string.Join(", ", this.TypeArguments));
|
||||
b.Append(DotNet35Compat.StringJoin(", ", this.TypeArguments));
|
||||
b.Append('>');
|
||||
}
|
||||
return b.ToString();
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace ICSharpCode.NRefactory.CSharp
|
|||
StringBuilder b = new StringBuilder(this.Identifier);
|
||||
if (this.TypeArguments.Any()) {
|
||||
b.Append('<');
|
||||
b.Append(string.Join(", ", this.TypeArguments));
|
||||
b.Append(DotNet35Compat.StringJoin(", ", this.TypeArguments));
|
||||
b.Append('>');
|
||||
}
|
||||
return b.ToString();
|
||||
|
|
|
@ -181,12 +181,34 @@ namespace ICSharpCode.NRefactory.CSharp
|
|||
RPar();
|
||||
}
|
||||
|
||||
void WriteCommaSeparatedListInBrackets(IEnumerable<AstNode> list)
|
||||
#if DOTNET35
|
||||
void WriteCommaSeparatedList(IEnumerable<VariableInitializer> list)
|
||||
{
|
||||
WriteCommaSeparatedList(list.SafeCast<VariableInitializer, AstNode>());
|
||||
}
|
||||
|
||||
void WriteCommaSeparatedList(IEnumerable<AstType> list)
|
||||
{
|
||||
WriteCommaSeparatedList(list.SafeCast<AstType, AstNode>());
|
||||
}
|
||||
|
||||
void WriteCommaSeparatedListInParenthesis(IEnumerable<Expression> list, bool spaceWithin)
|
||||
{
|
||||
WriteCommaSeparatedListInParenthesis(list.SafeCast<Expression, AstNode>(), spaceWithin);
|
||||
}
|
||||
|
||||
void WriteCommaSeparatedListInParenthesis(IEnumerable<ParameterDeclaration> list, bool spaceWithin)
|
||||
{
|
||||
WriteCommaSeparatedListInParenthesis(list.SafeCast<ParameterDeclaration, AstNode>(), spaceWithin);
|
||||
}
|
||||
#endif
|
||||
|
||||
void WriteCommaSeparatedListInBrackets(IEnumerable<Expression> list)
|
||||
{
|
||||
WriteToken("[", AstNode.Roles.LBracket);
|
||||
if (list.Any()) {
|
||||
Space(policy.SpacesWithinBrackets);
|
||||
WriteCommaSeparatedList(list);
|
||||
WriteCommaSeparatedList(list.SafeCast<Expression, AstNode>());
|
||||
Space(policy.SpacesWithinBrackets);
|
||||
}
|
||||
WriteToken("]", AstNode.Roles.RBracket);
|
||||
|
@ -354,7 +376,7 @@ namespace ICSharpCode.NRefactory.CSharp
|
|||
{
|
||||
if (typeParameters.Any()) {
|
||||
WriteToken("<", AstNode.Roles.LChevron);
|
||||
WriteCommaSeparatedList(typeParameters);
|
||||
WriteCommaSeparatedList(typeParameters.SafeCast<TypeParameterDeclaration, AstNode>());
|
||||
WriteToken(">", AstNode.Roles.RChevron);
|
||||
}
|
||||
}
|
||||
|
@ -1036,7 +1058,7 @@ namespace ICSharpCode.NRefactory.CSharp
|
|||
StartNode(queryOrderClause);
|
||||
WriteKeyword("orderby");
|
||||
Space();
|
||||
WriteCommaSeparatedList(queryOrderClause.Orderings);
|
||||
WriteCommaSeparatedList(queryOrderClause.Orderings.SafeCast<QueryOrdering, AstNode>());
|
||||
return EndNode(queryOrderClause);
|
||||
}
|
||||
|
||||
|
@ -1099,7 +1121,7 @@ namespace ICSharpCode.NRefactory.CSharp
|
|||
WriteToken(":", AttributeSection.Roles.Colon);
|
||||
Space();
|
||||
}
|
||||
WriteCommaSeparatedList(attributeSection.Attributes);
|
||||
WriteCommaSeparatedList(attributeSection.Attributes.SafeCast<Attribute, AstNode>());
|
||||
WriteToken("]", AstNode.Roles.RBracket);
|
||||
NewLine();
|
||||
return EndNode(attributeSection);
|
||||
|
@ -1348,7 +1370,7 @@ namespace ICSharpCode.NRefactory.CSharp
|
|||
LPar();
|
||||
Space(policy.WithinForParentheses);
|
||||
|
||||
WriteCommaSeparatedList(forStatement.Initializers);
|
||||
WriteCommaSeparatedList(forStatement.Initializers.SafeCast<Statement, AstNode>());
|
||||
WriteToken(";", AstNode.Roles.Semicolon);
|
||||
Space(policy.SpacesAfterSemicolon);
|
||||
|
||||
|
@ -1356,7 +1378,7 @@ namespace ICSharpCode.NRefactory.CSharp
|
|||
WriteToken(";", AstNode.Roles.Semicolon);
|
||||
Space(policy.SpacesAfterSemicolon);
|
||||
|
||||
WriteCommaSeparatedList(forStatement.Iterators);
|
||||
WriteCommaSeparatedList(forStatement.Iterators.SafeCast<Statement, AstNode>());
|
||||
|
||||
Space(policy.WithinForParentheses);
|
||||
RPar();
|
||||
|
|
|
@ -26,13 +26,22 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
|
|||
internal readonly CancellationToken cancellationToken;
|
||||
|
||||
#region Constructor
|
||||
public CSharpResolver(ITypeResolveContext context, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public CSharpResolver(ITypeResolveContext context)
|
||||
{
|
||||
if (context == null)
|
||||
throw new ArgumentNullException("context");
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
#if !DOTNET35
|
||||
public CSharpResolver(ITypeResolveContext context, CancellationToken cancellationToken)
|
||||
{
|
||||
if (context == null)
|
||||
throw new ArgumentNullException("context");
|
||||
this.context = context;
|
||||
this.cancellationToken = cancellationToken;
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
@ -1822,7 +1831,8 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
|
|||
} else {
|
||||
// No candidate found at all (not even an inapplicable one).
|
||||
// This can happen with empty method groups (as sometimes used with extension methods)
|
||||
return new UnknownMethodResolveResult(mgrr.TargetType, mgrr.MethodName, mgrr.TypeArguments, CreateParameters(arguments, argumentNames));
|
||||
return new UnknownMethodResolveResult(
|
||||
mgrr.TargetType, mgrr.MethodName, mgrr.TypeArguments, CreateParameters(arguments, argumentNames));
|
||||
}
|
||||
}
|
||||
UnknownMemberResolveResult umrr = target as UnknownMemberResolveResult;
|
||||
|
@ -1840,9 +1850,9 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
|
|||
return ErrorResult;
|
||||
}
|
||||
|
||||
static List<DefaultParameter> CreateParameters(ResolveResult[] arguments, string[] argumentNames)
|
||||
static List<IParameter> CreateParameters(ResolveResult[] arguments, string[] argumentNames)
|
||||
{
|
||||
List<DefaultParameter> list = new List<DefaultParameter>();
|
||||
List<IParameter> list = new List<IParameter>();
|
||||
if (argumentNames == null) {
|
||||
argumentNames = new string[arguments.Length];
|
||||
} else {
|
||||
|
|
|
@ -170,10 +170,10 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
|
|||
Predicate<IMember> memberFilter = delegate(IMember member) {
|
||||
return !member.IsOverride && member.Name == name && IsAccessible(member, allowProtectedAccess);
|
||||
};
|
||||
members.AddRange(type.GetMethods(context, memberFilter));
|
||||
members.AddRange(type.GetProperties(context, memberFilter));
|
||||
members.AddRange(type.GetFields(context, memberFilter));
|
||||
members.AddRange(type.GetEvents(context, memberFilter));
|
||||
members.AddRange(type.GetMethods(context, memberFilter.SafeCast<IMember, IMethod>()).SafeCast<IMethod, IMember>());
|
||||
members.AddRange(type.GetProperties(context, memberFilter.SafeCast<IMember, IProperty>()).SafeCast<IProperty, IMember>());
|
||||
members.AddRange(type.GetFields(context, memberFilter.SafeCast<IMember, IField>()).SafeCast<IField, IMember>());
|
||||
members.AddRange(type.GetEvents(context, memberFilter.SafeCast<IMember, IEvent>()).SafeCast<IEvent, IMember>());
|
||||
if (isInvocation)
|
||||
members.RemoveAll(m => !IsInvocable(m, context));
|
||||
} else {
|
||||
|
@ -183,7 +183,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
|
|||
return method.TypeParameters.Count == typeArgumentCount
|
||||
&& !method.IsOverride && method.Name == name && IsAccessible(method, allowProtectedAccess);
|
||||
};
|
||||
members.AddRange(type.GetMethods(context, memberFilter));
|
||||
members.AddRange(type.GetMethods(context, memberFilter).SafeCast<IMethod, IMember>());
|
||||
}
|
||||
|
||||
// TODO: can't members also hide types?
|
||||
|
|
|
@ -62,7 +62,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
|
|||
if (typeArguments.Count == 0)
|
||||
return target.ToString() + "." + identifier;
|
||||
else
|
||||
return target.ToString() + "." + identifier + "<" + string.Join(",", typeArguments) + ">";
|
||||
return target.ToString() + "." + identifier + "<" + DotNet35Compat.StringJoin(",", typeArguments) + ">";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -446,7 +446,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
|
|||
{
|
||||
bool c1IsBetter = false;
|
||||
bool c2IsBetter = false;
|
||||
foreach (var pair in t1.Zip<IType, IType, Tuple<IType, IType>>(t2, Tuple.Create)) {
|
||||
foreach (var pair in t1.Zip(t2, (a,b) => new { Item1 = a, Item2 = b })) {
|
||||
switch (MoreSpecificFormalParameter(pair.Item1, pair.Item2)) {
|
||||
case 1:
|
||||
c1IsBetter = true;
|
||||
|
|
|
@ -593,7 +593,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
|
|||
}
|
||||
}
|
||||
|
||||
ResolveResult[] GetArguments(IEnumerable<AstNode> argumentExpressions, out string[] argumentNames)
|
||||
ResolveResult[] GetArguments(IEnumerable<Expression> argumentExpressions, out string[] argumentNames)
|
||||
{
|
||||
argumentNames = null; // TODO: add support for named arguments
|
||||
ResolveResult[] arguments = new ResolveResult[argumentExpressions.Count()];
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
|
|||
if (typeArguments.Count == 0)
|
||||
return identifier;
|
||||
else
|
||||
return identifier + "<" + string.Join(",", typeArguments) + ">";
|
||||
return identifier + "<" + DotNet35Compat.StringJoin(",", typeArguments) + ">";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -856,7 +856,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
|
|||
bool success;
|
||||
IType[] result = InferTypeArgumentsFromBounds(
|
||||
candidateDef.TypeParameters,
|
||||
new ParameterizedType(candidateDef, candidateDef.TypeParameters),
|
||||
new ParameterizedType(candidateDef, candidateDef.TypeParameters.SafeCast<ITypeParameter, IType>()),
|
||||
lowerBounds, upperBounds,
|
||||
out success);
|
||||
if (success) {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>ICSharpCode.NRefactory</RootNamespace>
|
||||
<AssemblyName>ICSharpCode.NRefactory</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<ProductVersion>10.0.0</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
|
@ -15,6 +15,7 @@
|
|||
<NoStdLib>False</NoStdLib>
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<NoWarn>1591,0618</NoWarn>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
|
@ -27,24 +28,27 @@
|
|||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DebugType>Full</DebugType>
|
||||
<Optimize>False</Optimize>
|
||||
<DefineConstants>DEBUG;TRACE;FULL_AST</DefineConstants>
|
||||
<DefineConstants>DEBUG;TRACE;FULL_AST;DOTNET35</DefineConstants>
|
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DebugType>None</DebugType>
|
||||
<Optimize>True</Optimize>
|
||||
<DefineConstants>TRACE;FULL_AST</DefineConstants>
|
||||
<DefineConstants>TRACE;FULL_AST;DOTNET35</DefineConstants>
|
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugType>full</DebugType>
|
||||
<DebugType>Full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>none</DebugType>
|
||||
<DebugType>None</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
|
@ -322,6 +326,7 @@
|
|||
<Compile Include="Utils\BusyManager.cs" />
|
||||
<Compile Include="Utils\CacheManager.cs" />
|
||||
<Compile Include="Utils\CSharpPrimitiveCast.cs" />
|
||||
<Compile Include="Utils\DotNet35Compat.cs" />
|
||||
<Compile Include="Utils\EmptyList.cs" />
|
||||
<Compile Include="Utils\ExtensionMethods.cs" />
|
||||
<Compile Include="Utils\TreeTraversal.cs" />
|
||||
|
|
|
@ -297,7 +297,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
}
|
||||
}
|
||||
|
||||
static readonly string DynamicAttributeFullName = typeof(DynamicAttribute).FullName;
|
||||
const string DynamicAttributeFullName = "System.Runtime.CompilerServices.DynamicAttribute";
|
||||
|
||||
static bool HasDynamicAttribute(ICustomAttributeProvider attributeProvider, int typeIndex)
|
||||
{
|
||||
|
|
|
@ -70,15 +70,17 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
throw new ArgumentNullException("context");
|
||||
|
||||
HashSet<ITypeDefinition> typeDefinitions = new HashSet<ITypeDefinition>();
|
||||
Func<IType, IEnumerable<ITypeDefinition>> recursion =
|
||||
Func<ITypeDefinition, IEnumerable<ITypeDefinition>> recursion =
|
||||
t => t.GetBaseTypes(context).Select(b => b.GetDefinition()).Where(d => d != null && typeDefinitions.Add(d));
|
||||
|
||||
ITypeDefinition typeDef = type as ITypeDefinition;
|
||||
if (typeDef != null) {
|
||||
typeDefinitions.Add(typeDef);
|
||||
return TreeTraversal.PreOrder<ITypeDefinition>(typeDef, recursion);
|
||||
return TreeTraversal.PreOrder(typeDef, recursion);
|
||||
} else {
|
||||
return TreeTraversal.PreOrder<ITypeDefinition>(recursion(type), recursion);
|
||||
return TreeTraversal.PreOrder(
|
||||
type.GetBaseTypes(context).Select(b => b.GetDefinition()).Where(d => d != null && typeDefinitions.Add(d)),
|
||||
recursion);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,9 @@ 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 : IFreezable
|
||||
{
|
||||
|
@ -35,6 +37,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
IList<KeyValuePair<string, IConstantValue>> NamedArguments { get; }
|
||||
}
|
||||
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClassFor(typeof(IAttribute))]
|
||||
abstract class IAttributeContract : IFreezableContract, IAttribute
|
||||
{
|
||||
|
@ -63,4 +66,5 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -6,7 +6,9 @@ using System.Diagnostics.Contracts;
|
|||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem
|
||||
{
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClass(typeof(IConstantValueContract))]
|
||||
#endif
|
||||
public interface IConstantValue : IFreezable
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -30,6 +32,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
object GetValue(ITypeResolveContext context);
|
||||
}
|
||||
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClassFor(typeof(IConstantValue))]
|
||||
abstract class IConstantValueContract : IFreezableContract, IConstantValue
|
||||
{
|
||||
|
@ -46,4 +49,5 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
return null;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -7,7 +7,9 @@ using System.Diagnostics.Contracts;
|
|||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem
|
||||
{
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClass(typeof(IEntityContract))]
|
||||
#endif
|
||||
public interface IEntity : INamedElement, IFreezable
|
||||
{
|
||||
EntityType EntityType { get; }
|
||||
|
@ -75,6 +77,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
//bool IsAccessible(IClass callingClass, bool isAccessThoughReferenceOfCurrentClass);
|
||||
}
|
||||
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClassFor(typeof(IEntity))]
|
||||
abstract class IEntityContract : INamedElementContract, IEntity
|
||||
{
|
||||
|
@ -144,4 +147,5 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -9,7 +9,9 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
/// <summary>
|
||||
/// Represents an explicit interface implementation.
|
||||
/// </summary>
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClass(typeof(IExplicitInterfaceImplementationContract))]
|
||||
#endif
|
||||
public interface IExplicitInterfaceImplementation : IFreezable
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -23,6 +25,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
string MemberName { get; }
|
||||
}
|
||||
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClassFor(typeof(IExplicitInterfaceImplementation))]
|
||||
abstract class IExplicitInterfaceImplementationContract : IFreezableContract, IExplicitInterfaceImplementation
|
||||
{
|
||||
|
@ -40,4 +43,5 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -9,7 +9,9 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
/// <summary>
|
||||
/// Represents a field or constant.
|
||||
/// </summary>
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClass(typeof(IFieldContract))]
|
||||
#endif
|
||||
public interface IField : IMember, IVariable
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -28,6 +30,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
bool IsVolatile { get; }
|
||||
}
|
||||
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClassFor(typeof(IField))]
|
||||
abstract class IFieldContract : IMemberContract, IField
|
||||
{
|
||||
|
@ -63,4 +66,5 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
get { return null; }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -6,7 +6,9 @@ using System.Diagnostics.Contracts;
|
|||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem
|
||||
{
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClass(typeof(IFreezableContract))]
|
||||
#endif
|
||||
public interface IFreezable
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -20,6 +22,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
void Freeze();
|
||||
}
|
||||
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClassFor(typeof(IFreezable))]
|
||||
abstract class IFreezableContract : IFreezable
|
||||
{
|
||||
|
@ -33,4 +36,5 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
Contract.Ensures(self.IsFrozen);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -25,7 +25,9 @@ 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>
|
||||
|
@ -39,6 +41,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
IList<T> InternList<T>(IList<T> list) where T : class;
|
||||
}
|
||||
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClassFor(typeof(IInterningProvider))]
|
||||
abstract class IInterningProviderContract : IInterningProvider
|
||||
{
|
||||
|
@ -54,4 +57,5 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
return list;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -10,7 +10,9 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
/// <summary>
|
||||
/// Method/field/entity.
|
||||
/// </summary>
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClass(typeof(IMemberContract))]
|
||||
#endif
|
||||
public interface IMember : IEntity
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -58,6 +60,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
}
|
||||
}
|
||||
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClassFor(typeof(IMember))]
|
||||
abstract class IMemberContract : IEntityContract, IMember
|
||||
{
|
||||
|
@ -101,4 +104,5 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
get { return false; }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -10,7 +10,9 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
/// <summary>
|
||||
/// Represents a method, constructor, destructor or operator.
|
||||
/// </summary>
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClass(typeof(IMethodContract))]
|
||||
#endif
|
||||
public interface IMethod : IParameterizedMember
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -30,6 +32,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
bool IsOperator { get; }
|
||||
}
|
||||
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClassFor(typeof(IMethod))]
|
||||
abstract class IMethodContract : IParameterizedMemberContract, IMethod
|
||||
{
|
||||
|
@ -47,13 +50,6 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
}
|
||||
}
|
||||
|
||||
// IList<string> IMethod.HandlesClauses {
|
||||
// get {
|
||||
// Contract.Ensures(Contract.Result<IList<string>>() != null);
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
|
||||
bool IMethod.IsExtensionMethod {
|
||||
get { return false; }
|
||||
}
|
||||
|
@ -70,4 +66,5 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
get { return false; }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -6,7 +6,9 @@ using System.Diagnostics.Contracts;
|
|||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem
|
||||
{
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClass(typeof(INamedElementContract))]
|
||||
#endif
|
||||
public interface INamedElement
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -63,6 +65,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
}
|
||||
}
|
||||
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClassFor(typeof(INamedElement))]
|
||||
abstract class INamedElementContract : INamedElement
|
||||
{
|
||||
|
@ -94,4 +97,5 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -7,7 +7,9 @@ using System.Diagnostics.Contracts;
|
|||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem
|
||||
{
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClass(typeof(IParameterContract))]
|
||||
#endif
|
||||
public interface IParameter : IVariable, IFreezable
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -46,6 +48,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
bool IsOptional { get; }
|
||||
}
|
||||
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClassFor(typeof(IParameter))]
|
||||
abstract class IParameterContract : IVariableContract, IParameter
|
||||
{
|
||||
|
@ -92,4 +95,5 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -10,12 +10,15 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
/// <summary>
|
||||
/// Represents a method or property.
|
||||
/// </summary>
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClass(typeof(IParameterizedMemberContract))]
|
||||
#endif
|
||||
public interface IParameterizedMember : IMember
|
||||
{
|
||||
IList<IParameter> Parameters { get; }
|
||||
}
|
||||
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClassFor(typeof(IParameterizedMember))]
|
||||
abstract class IParameterizedMemberContract : IMemberContract, IParameterizedMember
|
||||
{
|
||||
|
@ -26,4 +29,5 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -10,12 +10,15 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
/// <summary>
|
||||
/// Mutable container of all classes in an assembly.
|
||||
/// </summary>
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClass(typeof(IProjectContentContract))]
|
||||
#endif
|
||||
public interface IProjectContent : ITypeResolveContext
|
||||
{
|
||||
IList<IAttribute> AssemblyAttributes { get; }
|
||||
}
|
||||
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClassFor(typeof(IProjectContent))]
|
||||
abstract class IProjectContentContract : ITypeResolveContextContract, IProjectContent
|
||||
{
|
||||
|
@ -26,4 +29,5 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -11,7 +11,9 @@ 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>
|
||||
|
@ -30,6 +32,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
bool EqualsForInterning(ISupportsInterning other);
|
||||
}
|
||||
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClassFor(typeof(ISupportsInterning))]
|
||||
abstract class ISupportsInterningContract : ISupportsInterning
|
||||
{
|
||||
|
@ -48,4 +51,5 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -7,7 +7,9 @@ using System.Diagnostics.Contracts;
|
|||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem
|
||||
{
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClass(typeof(ITypeContract))]
|
||||
#endif
|
||||
public interface IType : ITypeReference, INamedElement, IEquatable<IType>
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -90,6 +92,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
IEnumerable<IEvent> GetEvents(ITypeResolveContext context, Predicate<IEvent> filter = null);
|
||||
}
|
||||
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClassFor(typeof(IType))]
|
||||
abstract class ITypeContract : ITypeReferenceContract, IType
|
||||
{
|
||||
|
@ -209,4 +212,5 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
return this;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -10,7 +10,9 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
/// <summary>
|
||||
/// Represents a class, enum, interface, struct, delegate or VB module.
|
||||
/// </summary>
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClass(typeof(ITypeDefinitionContract))]
|
||||
#endif
|
||||
public interface ITypeDefinition : IType, IEntity
|
||||
{
|
||||
ClassType ClassType { get; }
|
||||
|
@ -44,6 +46,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
IEnumerable<IMember> Members { get; }
|
||||
}
|
||||
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClassFor(typeof(ITypeDefinition))]
|
||||
abstract class ITypeDefinitionContract : ITypeContract, ITypeDefinition
|
||||
{
|
||||
|
@ -181,4 +184,5 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
}
|
||||
#endregion
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -11,7 +11,9 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
/// <summary>
|
||||
/// Type parameter of a generic class/method.
|
||||
/// </summary>
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClass(typeof(ITypeParameterContract))]
|
||||
#endif
|
||||
public interface ITypeParameter : IType, IFreezable
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -99,6 +101,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
Contravariant
|
||||
};
|
||||
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClassFor(typeof(ITypeParameter))]
|
||||
abstract class ITypeParameterContract : ITypeContract, ITypeParameter
|
||||
{
|
||||
|
@ -178,4 +181,5 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -11,7 +11,9 @@ 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,
|
||||
|
@ -26,6 +28,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
IType Resolve(ITypeResolveContext context);
|
||||
}
|
||||
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClassFor(typeof(ITypeReference))]
|
||||
abstract class ITypeReferenceContract : ITypeReference
|
||||
{
|
||||
|
@ -36,4 +39,5 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
return null;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -12,7 +12,9 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
/// <summary>
|
||||
/// Context representing the set of assemblies in which a type is being searched.
|
||||
/// </summary>
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClass(typeof(ITypeResolveContextContract))]
|
||||
#endif
|
||||
public interface ITypeResolveContext
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -91,6 +93,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
CacheManager CacheManager { get; }
|
||||
}
|
||||
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClassFor(typeof(ITypeResolveContext))]
|
||||
abstract class ITypeResolveContextContract : ITypeResolveContext
|
||||
{
|
||||
|
@ -140,4 +143,5 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
return null;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -9,7 +9,9 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
/// <summary>
|
||||
/// Represents a variable (name/return type pair).
|
||||
/// </summary>
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClass(typeof(IVariableContract))]
|
||||
#endif
|
||||
public interface IVariable
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -33,6 +35,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
IConstantValue ConstantValue { get; }
|
||||
}
|
||||
|
||||
#if WITH_CONTRACTS
|
||||
[ContractClassFor(typeof(IVariable))]
|
||||
abstract class IVariableContract : IVariable
|
||||
{
|
||||
|
@ -62,4 +65,5 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|||
get { return null; }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -19,9 +19,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
|
|||
if (string.IsNullOrEmpty(ns)) {
|
||||
return name;
|
||||
} else {
|
||||
string combinedName = ns + "." + name;
|
||||
Contract.Assume(!string.IsNullOrEmpty(combinedName));
|
||||
return combinedName;
|
||||
return ns + "." + name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,19 +53,11 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
|
|||
base.FreezeInternal();
|
||||
}
|
||||
|
||||
[ContractInvariantMethod]
|
||||
void ObjectInvariant()
|
||||
{
|
||||
Contract.Invariant(type != null);
|
||||
Contract.Invariant(name != null);
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get { return name; }
|
||||
set {
|
||||
if (value == null)
|
||||
throw new ArgumentNullException();
|
||||
Contract.EndContractBlock();
|
||||
CheckBeforeMutation();
|
||||
name = value;
|
||||
}
|
||||
|
@ -76,7 +68,6 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
|
|||
set {
|
||||
if (value == null)
|
||||
throw new ArgumentNullException();
|
||||
Contract.EndContractBlock();
|
||||
CheckBeforeMutation();
|
||||
type = value;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,6 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
|
|||
throw new ArgumentNullException("declaringTypeDefinition");
|
||||
if (string.IsNullOrEmpty(name))
|
||||
throw new ArgumentException("name");
|
||||
Contract.EndContractBlock();
|
||||
this.projectContent = declaringTypeDefinition.ProjectContent;
|
||||
this.declaringTypeDefinition = declaringTypeDefinition;
|
||||
this.name = name;
|
||||
|
@ -73,20 +72,11 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
|
|||
throw new ArgumentNullException("projectContent");
|
||||
if (string.IsNullOrEmpty(name))
|
||||
throw new ArgumentException("name");
|
||||
Contract.EndContractBlock();
|
||||
this.projectContent = projectContent;
|
||||
this.ns = ns ?? string.Empty;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
[ContractInvariantMethod]
|
||||
void ObjectInvariant()
|
||||
{
|
||||
Contract.Invariant(projectContent != null);
|
||||
Contract.Invariant(!string.IsNullOrEmpty(name));
|
||||
Contract.Invariant(ns != null);
|
||||
}
|
||||
|
||||
public ClassType ClassType {
|
||||
get { return classType; }
|
||||
set {
|
||||
|
@ -164,7 +154,10 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
|
|||
|
||||
public IEnumerable<IMember> Members {
|
||||
get {
|
||||
return this.Fields.Concat<IMember>(this.Properties).Concat(this.Methods).Concat(this.Events);
|
||||
return this.Fields.SafeCast<IField, IMember>()
|
||||
.Concat(this.Properties.SafeCast<IProperty, IMember>())
|
||||
.Concat(this.Methods.SafeCast<IMethod, IMember>())
|
||||
.Concat(this.Events.SafeCast<IEvent, IMember>());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,15 +180,11 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
|
|||
public string FullName {
|
||||
get {
|
||||
if (declaringTypeDefinition != null) {
|
||||
string combinedName = declaringTypeDefinition.FullName + "." + this.name;
|
||||
Contract.Assume(!string.IsNullOrEmpty(combinedName));
|
||||
return combinedName;
|
||||
return declaringTypeDefinition.FullName + "." + this.name;
|
||||
} else if (string.IsNullOrEmpty(ns)) {
|
||||
return this.name;
|
||||
} else {
|
||||
string combinedName = this.ns + "." + this.name;
|
||||
Contract.Assume(!string.IsNullOrEmpty(combinedName));
|
||||
return combinedName;
|
||||
return this.ns + "." + this.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
|
@ -51,16 +52,27 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
|
|||
}
|
||||
}
|
||||
|
||||
sealed class ListComparer : IEqualityComparer<IEnumerable<object>>
|
||||
sealed class ListComparer : IEqualityComparer<IEnumerable>
|
||||
{
|
||||
public bool Equals(IEnumerable<object> a, IEnumerable<object> b)
|
||||
public bool Equals(IEnumerable a, IEnumerable b)
|
||||
{
|
||||
if (a.GetType() != b.GetType())
|
||||
return false;
|
||||
return Enumerable.SequenceEqual(a, b, ReferenceComparer.Instance);
|
||||
IEnumerator e1 = a.GetEnumerator();
|
||||
IEnumerator e2 = b.GetEnumerator();
|
||||
while (e1.MoveNext()) {
|
||||
// e1 has more elements than e2; or elements are different
|
||||
if (!e2.MoveNext() || e1.Current != e2.Current)
|
||||
return false;
|
||||
}
|
||||
if (e2.MoveNext()) // e2 has more elements than e1
|
||||
return false;
|
||||
// No need to dispose e1/e2: non-generic IEnumerator doesn't implement IDisposable,
|
||||
// and the underlying enumerator will likely be a List<T>.Enumerator which has an empty Dispose() method.
|
||||
return true;
|
||||
}
|
||||
|
||||
public int GetHashCode(IEnumerable<object> obj)
|
||||
public int GetHashCode(IEnumerable obj)
|
||||
{
|
||||
int hashCode = obj.GetType().GetHashCode();
|
||||
unchecked {
|
||||
|
@ -75,7 +87,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
|
|||
|
||||
Dictionary<object, object> byValueDict = new Dictionary<object, object>();
|
||||
Dictionary<ISupportsInterning, ISupportsInterning> supportsInternDict = new Dictionary<ISupportsInterning, ISupportsInterning>(new InterningComparer());
|
||||
Dictionary<IEnumerable<object>, IEnumerable<object>> listDict = new Dictionary<IEnumerable<object>, IEnumerable<object>>(new ListComparer());
|
||||
Dictionary<IEnumerable, IEnumerable> listDict = new Dictionary<IEnumerable, IEnumerable>(new ListComparer());
|
||||
|
||||
public T Intern<T>(T obj) where T : class
|
||||
{
|
||||
|
@ -118,7 +130,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
|
|||
}
|
||||
if (!list.IsReadOnly)
|
||||
list = new ReadOnlyCollection<T>(list);
|
||||
IEnumerable<object> output;
|
||||
IEnumerable output;
|
||||
if (listDict.TryGetValue(list, out output))
|
||||
list = (IList<T>)output;
|
||||
else
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
internal static class DotNet35Compat
|
||||
{
|
||||
public static string StringJoin<T>(string separator, IEnumerable<T> elements)
|
||||
{
|
||||
#if DOTNET35
|
||||
return string.Join(separator, elements.Select(e => e != null ? e.ToString() : null).ToArray());
|
||||
#else
|
||||
return string.Join(separator, elements);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static IEnumerable<U> SafeCast<T, U>(this IEnumerable<T> elements) where T : U
|
||||
{
|
||||
#if DOTNET35
|
||||
foreach (T item in elements)
|
||||
yield return item;
|
||||
#else
|
||||
return elements;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static Predicate<U> SafeCast<T, U>(this Predicate<T> predicate) where U : T
|
||||
{
|
||||
#if DOTNET35
|
||||
return e => predicate(e);
|
||||
#else
|
||||
return predicate;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if DOTNET35
|
||||
public static IEnumerable<R> Zip<T1, T2, R>(this IEnumerable<T1> input1, IEnumerable<T2> input2, Func<T1, T2, R> f)
|
||||
{
|
||||
using (var e1 = input1.GetEnumerator())
|
||||
using (var e2 = input2.GetEnumerator())
|
||||
while (e1.MoveNext() && e2.MoveNext())
|
||||
yield return f(e1.Current, e2.Current);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if DOTNET35
|
||||
namespace System.Diagnostics.Contracts { }
|
||||
namespace System.Threading
|
||||
{
|
||||
internal struct CancellationToken
|
||||
{
|
||||
public void ThrowIfCancellationRequested() {}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -71,13 +71,13 @@ Global
|
|||
{870115DD-960A-4406-A6B9-600BCDC36A03}.Release|x86.Build.0 = Release|Any CPU
|
||||
{870115DD-960A-4406-A6B9-600BCDC36A03}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|Any CPU.Build.0 = net_4_0_Debug|Any CPU
|
||||
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|Any CPU.ActiveCfg = net_4_0_Debug|Any CPU
|
||||
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|Any CPU.ActiveCfg = net_3_5_Debug|Any CPU
|
||||
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|x86.Build.0 = net_4_0_Debug|Any CPU
|
||||
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|x86.ActiveCfg = net_4_0_Debug|Any CPU
|
||||
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|x86.ActiveCfg = net_3_5_Debug|Any CPU
|
||||
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Release|Any CPU.Build.0 = net_4_0_Debug|Any CPU
|
||||
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU
|
||||
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Release|Any CPU.ActiveCfg = net_3_5_Release|Any CPU
|
||||
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Release|x86.Build.0 = net_4_0_Debug|Any CPU
|
||||
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Release|x86.ActiveCfg = net_4_0_Release|Any CPU
|
||||
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Release|x86.ActiveCfg = net_3_5_Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(MonoDevelopProperties) = preSolution
|
||||
StartupItem = ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
|
|
Загрузка…
Ссылка в новой задаче