public void SetTest()
        {
            AnonymousType anonymousType = new AnonymousType {Namespace = nmspc};
            resolvedResult = new MemberResolveResult(anonymousType);
            resolvedResult.CallingType = anonymousType;
            resolvedResult.ResolvedExpression = new ExpressionResult(clsName);
            ctx.Stub(p=>p.GetResolvedTypeNameResult()).Return(resolvedResult);
            ctx.Stub(p=>p.GetCurrentFilePath()).Return(new FilePath(dir + fileName));

            resolver.Stub(r=>r.GetNewTypeContent(Arg<string>.Is.Anything, Arg<string>.Is.Anything, Arg<string>.Is.Anything)).Return (fileContent);

            changes = generateClassRefactoring.PerformChanges(null, null);
        }
Exemplo n.º 2
0
		IType CreateAnonymousClass (CollectionInitializerExpression initializer)
		{
			DomType result;
			if (!anonymousTypes.TryGetValue (initializer, out result)) {
				result = new AnonymousType ();
				result.SourceProjectDom = resolver.Dom;
				foreach (Expression expr in initializer.CreateExpressions) {
					var oldPos = resolver.ResolvePosition;
					if (!expr.StartLocation.IsEmpty)
						resolver.resolvePosition = new DomLocation (expr.StartLocation.Line + resolver.CallingMember.Location.Line, expr.StartLocation.Column);
					DomProperty newProperty = new DomProperty (GetAnonymousTypeFieldName (expr), MonoDevelop.Projects.Dom.Modifiers.Public, DomLocation.Empty, DomRegion.Empty, ResolveType (expr));
					newProperty.DeclaringType = result;
					result.Add (newProperty);
					resolver.resolvePosition = oldPos;
				}
				anonymousTypes[initializer] = result;
			}
			return result;
		}
		IType CreateAnonymousClass (CollectionInitializerExpression initializer)
		{
			DomType result = new AnonymousType ();
			result.SourceProjectDom = resolver.Dom;
			foreach (Expression expr in initializer.CreateExpressions) {
				DomProperty newProperty = new DomProperty (GetAnonymousTypeFieldName (expr), MonoDevelop.Projects.Dom.Modifiers.Public, DomLocation.Empty, DomRegion.Empty, ResolveType(expr));
				newProperty.DeclaringType = result;
				result.Add (newProperty);
			}
			return result;
		}