private static bool IsTheoryPropertyDataProperty(ITypeMember element)
        {
            if (element.IsStatic && element.GetAccessRights() == AccessRights.PUBLIC)
            {
                // Make sure there is a containing type. The only example I've seen where this is null
                // is when the C# class is included in the project, but not compiled (i.e. build action
                // is set to None). Not sure if this is a bug or not - on the one hand, it's not compiled
                // so there isn't really a type there, on the other, there's enough info for it to be
                // a method, and that method has to live somewhere. Either way, we don't care. If it's
                // not compiled, it's no use to the test runner
                var containingType = element.GetContainingType();
                if (containingType == null)
                    return false;

                // According to msdn, parameters to the constructor are positional parameters, and any
                // public read-write fields are named parameters. The name of the property we're after
                // is not a public field/property, so it's a positional parameter
                var propertyNames = from method in containingType.Methods
                                    from attributeInstance in method.GetAttributeInstances(PropertyDataAttributeName, false)
                                    select attributeInstance.PositionParameter(0).ConstantValue.Value as string;
                return propertyNames.Any(name => name == element.ShortName);
            }

            return false;
        }
    protected override int CompareTypeMember(ITypeMember x, ITypeMember y)
    {
      DeclaredElementType xType = x.GetElementType();
      DeclaredElementType yType = y.GetElementType();
      if (xType.Equals(yType))
        return base.CompareTypeMember(x, y);

      return StringComparer.InvariantCultureIgnoreCase.Compare(xType.PresentableName, yType.PresentableName);
    }
        public static bool IsColorProperty(ITypeMember typeMember)
        {
            if (typeMember is IProperty && typeMember.IsStatic)
            {
                var unityColorTypes = GetInstance(typeMember.Module);
                return unityColorTypes.IsUnityColorTypeSupportingProperties(typeMember.GetContainingType())
                       && UnityNamedColors.Get(typeMember.ShortName).HasValue;
            }

            return false;
        }
 public static void InsertAfterInitialFields(this IClass cl, ITypeMember member)
 {
     IField lastField = null;
      foreach (var m in cl.Members)
      {
     if (m is IField) { lastField = m as IField; }
     else { break; }
      }
      if (lastField == null) cl.MembersAll.InsertOrMove(0, member);
      else { cl.MembersAll.InsertOrMoveAfter(lastField, member); }
 }
        private static bool IsTheoryPropertyDataProperty(ITypeMember element)
        {
            if (element.IsStatic && element.GetAccessRights() == AccessRights.PUBLIC)
            {
                // According to msdn, parameters to the constructor are positional parameters, and any
                // public read-write fields are named parameters. The name of the property we're after
                // is not a public field/property, so it's a positional parameter
                var propertyNames = from method in element.GetContainingType().Methods
                                    from attributeInstance in method.GetAttributeInstances(PropertyDataAttributeName, false)
                                    select attributeInstance.PositionParameter(0).ConstantValue.Value as string;
                return propertyNames.Any(name => name == element.ShortName);
            }

            return false;
        }
 public void AddAssignmentToBody(IConstructorDeclaration constructorDeclaration, IStatement anchorStatement,
     bool insertBefore, IParameter parameter, ITypeMember member)
 {
     var constructorDeclaration1 = constructorDeclaration;
     var instance = CSharpElementFactory.GetInstance(constructorDeclaration1);
     if (constructorDeclaration1.Body == null)
         constructorDeclaration1.SetBody(instance.CreateEmptyBlock());
     var shortName1 = parameter.ShortName;
     var shortName2 = member.ShortName;
     var statement = instance.CreateStatement("$0 = $1;", (object) shortName2, (object) shortName1);
     CodeStyleUtil.ApplyRecursive<ThisQualifierStyleSuggestion>(insertBefore
         ? constructorDeclaration1.Body.AddStatementBefore(statement,
             (ICSharpStatement) anchorStatement)
         : constructorDeclaration1.Body.AddStatementAfter(statement,
             (ICSharpStatement) anchorStatement));
 }
 public override string GetNativeCallConversion(string expr, ITypeMember m)
 {
     switch (m.PassedByType)
     {
         case PassedByType.Reference:
         case PassedByType.Value:
             return expr;
         case PassedByType.PointerPointer:
         case PassedByType.Pointer:
         default:
             throw new Exception("Unexpected");
     }
 }
 public override string GetCLRTypeName(ITypeMember m)
 {
     switch (m.PassedByType)
     {
         case PassedByType.Reference:
         case PassedByType.Value:
             return FullCLRName + "^";
         case PassedByType.PointerPointer:
         case PassedByType.Pointer:
         default:
             throw new Exception("Unexpected");
     }
 }
 public override string GetNativeCallConversion(string expr, ITypeMember m)
 {
     switch (m.PassedByType)
     {
         case PassedByType.Reference:
         case PassedByType.Pointer:
             return expr;
         case PassedByType.Value:
             if (m.IsConst || this.IsReadOnly)
                 return FullCLRName + "::ByValue( " + expr + " )->ReadOnlyInstance";
             else
                 return FullCLRName + "::ByValue( " + expr + " )";
         case PassedByType.PointerPointer:
         default:
             throw new Exception("Unexpected");
     }
 }
        private ConstantValue2 GetAttributeNamedParameterHack(IAttributeInstance attributeInstance, ITypeMember typeMember)
        {
            IAttribute attribute = GetCSharpAttributeHack(attributeInstance);
            if (attribute != null)
            {
                foreach (IPropertyAssignmentNode propertyAssignmentNode in attribute.ToTreeNode().PropertyAssignments)
                {
                    IPropertyAssignment propertyAssignment = propertyAssignmentNode;
                    if (propertyAssignment.Reference.Resolve().DeclaredElement == typeMember)
                    {
                        IType propertyType = ((ITypeOwner)typeMember).Type;
                        ICSharpExpression expression = propertyAssignment.Source;
                        return GetCSharpConstantValueHack(expression, propertyType);
                    }
                }

                return ConstantValue2.BAD_VALUE;
            }

            return attributeInstance.NamedParameter(typeMember);
        }
 public override string GetCLRTypeName(ITypeMember m)
 {
     switch (m.PassedByType)
     {
         case PassedByType.Value:
             return Name;
         case PassedByType.Pointer:
             if (IsVoid)
             {
                 return "void*";
             }
             else if (m.HasAttribute<ArrayTypeAttribute>())
             {
                 return "array<" + FullCLRName + ">^";
             }
             else
             {
                 string name = Name + "*";
                 if (m.IsConst) name = "const " + name;
                 return name;
             }
         case PassedByType.Reference:
         case PassedByType.PointerPointer:
         default:
             throw new Exception("Unexpected");
     }
 }
 public override string GetNativeCallConversion(string expr, ITypeMember m)
 {
     switch (m.PassedByType)
     {
         case PassedByType.Reference:
         case PassedByType.Value:
             return "ToManaged<" + ConversionTypeName + ", " + FullNativeName + ">( " + expr + " )";
         case PassedByType.PointerPointer:
         case PassedByType.Pointer:
         default:
             throw new Exception("Unexpected");
     }
 }
Example #13
0
 ///<summary>
 ///
 ///            Check if the given type member is visible in this language
 ///            
 ///</summary>
 ///
 ///<returns>
 ///
 ///</returns>
 ///
 public override bool IsTypeMemberVisible(ITypeMember member)
 {
     return base.IsTypeMemberVisible(member);
 }
 protected virtual string GetCLRTypeName(ITypeMember m)
 {
     AddTypeDependancy(m.Type);
     if (m.Type.IsUnnamedSTLContainer)
         return GetClassName() + "::" + m.CLRTypeName;
     else
         return m.CLRTypeName;
 }
Example #15
0
        protected virtual bool? CheckTypeMemberForGetProperty(ITypeMember m)
        {
            if (!m.Type.IsValueType && (m.Type.IsSharedPtr || m.Type is DefTemplateOneType || m.Type is DefTemplateTwoTypes))
                return false;

            if (m.Type.HasAttribute<ReturnOnlyByMethodAttribute>())
                return false;

            return null;
        }
 public override string GetCLRTypeName(ITypeMember m)
 {
     switch (m.PassedByType)
     {
         case PassedByType.Reference:
         case PassedByType.Pointer:
             if (m.IsConst)
                 return FullCLRName.Replace(CLRName, "Const_" + CLRName) + "^";
             else
                 return FullCLRName + "^";
         case PassedByType.Value:
             if (m.IsConst || this.IsReadOnly)
                 return FullCLRName.Replace(CLRName, "Const_" + CLRName) + "^";
             else
                 return FullCLRName + "^";
         case PassedByType.PointerPointer:
         default:
             throw new Exception("Unexpected");
     }
 }
Example #17
0
        protected virtual bool IsUnhandledType(ITypeMember m)
        {
            if (m.Type.IsIgnored)
                return true;

            if (m.Type is DefClass && (m.Type as DefClass).IsSingleton)
                return true;

            switch (m.TypeName)
            {
                case "UserDefinedObject":
                    return true;
                default:
                    return false;
            }
        }
 public override string GetNativeCallConversion(string expr, ITypeMember m)
 {
     switch (m.PassedByType)
     {
         case PassedByType.Reference:
             //Could be called from NativeClass producer
         case PassedByType.Value:
             return expr;
         case PassedByType.Pointer:
             if (IsVoid)
             {
                 return expr;
             }
             else if (m.HasAttribute<ArrayTypeAttribute>())
             {
                 int len = m.GetAttribute<ArrayTypeAttribute>().Length;
                 return "GetValueArrayFromNativeArray<" + FullCLRName + ", " + FullNativeName + ">( " + expr + " , " + len + " )";
             }
             else
                 return expr;
         case PassedByType.PointerPointer:
         default:
             throw new Exception("Unexpected");
     }
 }
        private ConstantValue? GetAttributeNamedParameter(IAttributeInstance attributeHandle, ITypeMember memberHandle)
        {
#if RESHARPER_31
            ConstantValue2 rawValue = GetAttributeNamedParameterHack(attributeHandle, memberHandle);
            return rawValue.IsBadValue() ? (ConstantValue?)null : ConvertConstantValue(rawValue.Value);
#else
            AttributeValue rawValue = attributeHandle.NamedParameter(memberHandle);
            return rawValue.IsBadValue ? (ConstantValue?) null : ConvertConstantValue(rawValue);
#endif
        }
Example #20
0
 protected virtual string GetCLRTypeName(ITypeMember m)
 {
     CheckTypeForDependancy(m.Type);
     return m.CLRTypeName;
 }