Exemplo n.º 1
0
        /// <summary>
        /// method returns the String
        /// </summary>
        public override string ToString()
        {
            // initial value
            string info = "";

            // if Exclude
            if (Exclude)
            {
                // set the return value
                info = "Exclude: true ";
            }
            else
            {
                // set the return value
                info = "Exclude: false ";
            }

            // set the info
            info += " Table Id " + TableId.ToString();

            // if Field
            if (ObjectType == ExcludeObjectTypeEnum.Field)
            {
                // set the info
                info += " Field Id " + FieldId.ToString();
            }

            // return value
            return(info);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Configures the specified property info.
        /// </summary>
        /// <param name="propertyInfo">The property info.</param>
        /// <param name="config">The config.</param>
        public void Configure(PropertyInfo propertyInfo, SitecoreFieldConfiguration config)
        {
            config.FieldName = this.FieldName;

            if (config.FieldName.IsNullOrEmpty())
            {
                config.FieldName = propertyInfo.Name;
            }

            if (FieldId.HasValue())
            {
                config.FieldId = new ID(this.FieldId);
            }


            config.Setting         = this.Setting;
            config.MediaUrlOptions = MediaUrlOptions;
            config.UrlOptions      = UrlOptions;



            //code first configuration
            var fieldFieldValues = propertyInfo.GetCustomAttributes(typeof(SitecoreFieldFieldValueAttribute), true).Cast <SitecoreFieldFieldValueAttribute>();

            ////fix: fieldfieldvalues are not passed
            var interfaceFromProperty = propertyInfo.DeclaringType.GetInterfaces().FirstOrDefault(inter => inter.GetProperty(propertyInfo.Name) != null);

            if (interfaceFromProperty != null)
            {
                fieldFieldValues = interfaceFromProperty.GetProperty(propertyInfo.Name).GetCustomAttributes(typeof(SitecoreFieldFieldValueAttribute), true).Cast <SitecoreFieldFieldValueAttribute>();;
            }

            base.Configure(propertyInfo, config);
        }
Exemplo n.º 3
0
        public void TryGetDocumentationComments_gets_expected_docs_for_a_field()
        {
            // ARRANGE
            var cs = @"
	            using System;

	            public class Class1
	            {
                    /// <summary>
                    /// Summary
                    /// </summary>
                    /// <remarks>Remarks</remarks>
                    /// <example>Example</example>
                    /// <value>Value</value>
                    /// <seealso cref=""Class2"">Some text</seealso>
                    /// <seealso cref=""Interface1"" />
                    public string Field1;
                }

                public class Class2
                { }

                public interface Interface1
                { }
            ";

            using var assembly = Compile(cs, out var xmlDocs);

            var id = new FieldId(new SimpleTypeId(NamespaceId.GlobalNamespace, "Class1"), "Field1");

            // ACT
            var sut  = new XmlDocsProvider(assembly, xmlDocs, NullLogger.Instance);
            var docs = sut.TryGetDocumentationComments(id);

            // ASSERT
            Assert.NotNull(docs);

            Assert.NotNull(docs !.MemberId);
            Assert.IsAssignableFrom <FieldId>(docs.MemberId);

            Assert.NotNull(docs.Summary);

            Assert.NotNull(docs.Remarks);

            Assert.NotNull(docs.Example);

            Assert.NotNull(docs.Value);

            Assert.All(docs.SeeAlso, seeAlso => Assert.NotNull(seeAlso.MemberId));

            Assert.Equal(2, docs.SeeAlso.Count);
            Assert.Contains(
                docs.SeeAlso,
                seeAlso => seeAlso.Text.Elements.Count == 1 && seeAlso.MemberId !.Equals(new SimpleTypeId(NamespaceId.GlobalNamespace, "Class2"))
                );
            Assert.Contains(
                docs.SeeAlso,
                seeAlso => seeAlso.Text.Elements.Count == 0 && seeAlso.MemberId !.Equals(new SimpleTypeId(NamespaceId.GlobalNamespace, "Interface1"))
                );
        }
Exemplo n.º 4
0
 public void Deserialize(IXunitSerializationInfo info)
 {
     FieldId = new FieldId(
         definingType: info.GetValue <XunitSerializableTypeId>(nameof(FieldId.DefiningType)),
         name: info.GetValue <string>(nameof(FieldId.Name))
         );
 }
Exemplo n.º 5
0
        /// <inheritdoc />
        protected override string FieldToString(FieldId field, RowVersion version)
        {
            return(field switch
            {
                FieldId.ProvinceState when version == RowVersion.JHopkinsV1 || version == RowVersion.JHopkinsV2 => "Province/State",
                FieldId.ProvinceState => "Province_State",

                FieldId.CountryRegion when version == RowVersion.JHopkinsV1 || version == RowVersion.JHopkinsV2 => "Country/Region",
                FieldId.CountryRegion => "Country_Region",

                FieldId.LastUpdate when version == RowVersion.JHopkinsV1 || version == RowVersion.JHopkinsV2 => "Last Update",
                FieldId.LastUpdate => "Last_Update",

                FieldId.Latitude when version == RowVersion.JHopkinsV1 || version == RowVersion.JHopkinsV2 => field.ToString(),
                FieldId.Latitude => "Lat",

                FieldId.Longitude when version == RowVersion.JHopkinsV1 || version == RowVersion.JHopkinsV2 => field.ToString(),
                FieldId.Longitude => "Long_",

                FieldId.CombinedKey => "Combined_Key",

                FieldId.IncidenceRate when version == RowVersion.JHopkinsV4 => "Incidence_Rate",
                FieldId.IncidenceRate when version == RowVersion.JHopkinsV5 => "Incident_Rate",

                FieldId.CaseFatalityRatio when version == RowVersion.JHopkinsV4 => "Case-Fatality_Ratio",
                FieldId.CaseFatalityRatio when version == RowVersion.JHopkinsV5 => "Case_Fatality_Ratio",


                _ => field.ToString()
            });
Exemplo n.º 6
0
        /// <inheritdoc />
        protected override string FieldToString(FieldId field, RowVersion version)
        {
            return(field switch
            {
                FieldId.Iso2 when version == RowVersion.StatsBase => "iso2",
                FieldId.Iso3 when version == RowVersion.StatsBase => "iso3",
                FieldId.Code3 when version == RowVersion.StatsBase => "code3",
                FieldId.CountryRegion when version == RowVersion.StatsBase => "Country_Region",

                FieldId.Iso2 when version == RowVersion.StatsEx => "Two_Letter_Country_Code",
                FieldId.Iso3 when version == RowVersion.StatsEx => "Three_Letter_Country_Code",
                FieldId.Code3 when version == RowVersion.StatsEx => "Country_Number",
                FieldId.CountryRegion when version == RowVersion.StatsEx => "Country_Name",

                FieldId.ProvinceState => "Province_State",
                FieldId.Latitude => "Lat",
                FieldId.Longitude => "Long_",
                FieldId.CombinedKey => "Combined_Key",

                FieldId.ContinentName => "Continent_Name",
                FieldId.ContinentCode => "Continent_Code",

                FieldId.English => "English_JHopkins",
                FieldId.Russian => "Russian_Yandex",

                _ => field.ToString()
            });
Exemplo n.º 7
0
 /// <summary>
 /// Returns the value of one or more static fields of the reference type. Each field must be member of the reference type or 
 /// one of its superclasses, superinterfaces, or implemented interfaces. Access control is not enforced; for example, the values 
 /// of private fields can be obtained.
 /// </summary>
 public Task<List<Value>> GetValuesAsync(ReferenceTypeId typeId, FieldId[] fields)
 {
     var conn = ConnectionOrError;
     var sizeInfo = conn.GetIdSizeInfo();
     var t = conn.SendAsync(JdwpPacket.CreateCommand(conn, Nr, 6, typeId.Size + 4 + (sizeInfo.FieldIdSize * fields.Length),
         x => {
             var data = x.Data;
             typeId.WriteTo(data);
             data.SetInt(fields.Length);
             foreach (var fieldId in fields)
             {
                 fieldId.WriteTo(data);
             }
         }));
     return t.ContinueWith(x => {
         x.ForwardException();
         var result = x.Result;
         result.ThrowOnError();
         var data = result.Data;
         var count = data.GetInt();
         var list = new List<Value>(count);
         for (var i = 0; i < count; i++)
         {
             var value = new Value(data);
             list.Add(value);
         }
         return list;
     });
 }
Exemplo n.º 8
0
        public void SendXmlAndTextMatch(bool matchAll)
        {
            XElement[] elementList = new XElement[2];

            elementList[0] = DeltaXml;
            elementList[0].SetAttributeValue(Common.BypassAKProcessing, "1");

            elementList[1] = new XElement(Common.Requests.MenuAction);

            if (matchAll)
            {
                elementList[1].SetAttributeValue(Common.MenuAction, Common.MENUACTION_TextMatchAll);
            }
            else
            {
                elementList[1].SetAttributeValue(Common.MenuAction, Common.MENUACTION_TextMatch);
            }

            if (this.FieldId.IndexOf(".") >= 0)
            {
                elementList[1].SetAttributeValue(Common.referenceObject, FieldId.Substring(0, FieldId.LastIndexOf(".")));
            }

            _controlHarness.SendXml(elementList);
        }
Exemplo n.º 9
0
 public static FieldId GetFieldId(string fieldNameOrId)
 {
     if (!String.IsNullOrWhiteSpace(fieldNameOrId))
     {
         int val;
         if (int.TryParse(fieldNameOrId, out val))
         {
             if ((val >= 0) && (val < (int)(FieldId.NullField)))
             {
                 return((FieldId)val);
             }
         }
         else
         {
             FieldId id = FieldId.IndexField;
             fieldNameOrId = fieldNameOrId.ToLower();
             foreach (string s in FieldNames)
             {
                 if (s.StartsWith(fieldNameOrId))
                 {
                     return(id);
                 }
                 ++id;
             }
         }
     }
     return(FieldId.NullField);
 }
        public IDictionary <IField, IValue> GetValues(IEnumerable <IField> fields)
        {
            IField[] fieldsArray = fields.ToArray();

            FieldId[] fieldIds = new FieldId[fieldsArray.Length];
            // verify each field comes from this VM
            for (int i = 0; i < fieldsArray.Length; i++)
            {
                Field field = fieldsArray[i] as Field;
                if (field == null)
                {
                    throw new VirtualMachineMismatchException();
                }

                fieldIds[i] = field.FieldId;
            }

            Types.Value[] values;
            DebugErrorHandler.ThrowOnFailure(VirtualMachine.ProtocolService.GetReferenceTypeValues(out values, ReferenceTypeId, fieldIds));

            Dictionary <IField, IValue> result = new Dictionary <IField, IValue>();

            for (int i = 0; i < fieldIds.Length; i++)
            {
                result[fieldsArray[i]] = VirtualMachine.GetMirrorOf(values[i]);
            }

            return(result);
        }
Exemplo n.º 11
0
 public DeclaredFieldData(FieldId fieldId, string name, string signature, string genericSignature, AccessModifiers modifiers)
 {
     FieldId = fieldId;
     Name = name;
     Signature = signature;
     GenericSignature = genericSignature;
     Modifiers = modifiers;
 }
Exemplo n.º 12
0
        public void UpdateItem([NotNull] ItemUri itemUri, [NotNull] FieldId fieldId, [NotNull] string value)
        {
            Assert.ArgumentNotNull(itemUri, nameof(itemUri));
            Assert.ArgumentNotNull(fieldId, nameof(fieldId));
            Assert.ArgumentNotNull(value, nameof(value));

            ItemModifier.Edit(itemUri, fieldId, value);
        }
Exemplo n.º 13
0
        public static String Get(FieldId id)
        {
            if (_dic.TryGetValue(id, out var name))
            {
                return(name);
            }

            return($"Unknown field: {id}");
        }
Exemplo n.º 14
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((FieldId.GetHashCode() * 397) ^
                (Language == null ? 0 : StringComparer.OrdinalIgnoreCase.GetHashCode(Language)) ^
                Version.GetHashCode());
     }
 }
Exemplo n.º 15
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Serves as a hash function for a particular type.
 /// </summary>
 /// <returns>
 /// A hash code for the current <see cref="T:System.Object"/>.
 /// </returns>
 /// <filterpriority>2</filterpriority>
 /// ------------------------------------------------------------------------------------
 public override int GetHashCode()
 {
     unchecked
     {
         int result = (FieldId != null ? FieldId.GetHashCode() : 0);
         result = (result * 397) ^ (Type != null ? Type.GetHashCode() : 0);
         result = (result * 397) ^ (ValueAsString != null ? ValueAsString.GetHashCode() : 0);
         return(result);
     }
 }
Exemplo n.º 16
0
        public override void Execute(object parameter)
        {
            var context = parameter as IItemSelectionContext;

            if (context == null)
            {
                return;
            }

            var item = context.Items.FirstOrDefault() as ITemplatedItem;

            if (item == null)
            {
                return;
            }

            var parentUri   = item.ItemUri;
            var templateUri = new ItemUri(item.ItemUri.DatabaseUri, IdManager.GetItemId("/sitecore/templates/System/Templates/Template"));

            var parameterTemplateUri = parentUri.Site.DataService.AddFromTemplate(parentUri, templateUri, item.Name + @"-Parameters");

            if (parameterTemplateUri == ItemUri.Empty)
            {
                return;
            }

            AppHost.Server.UpdateItem(parameterTemplateUri, BaseTemplateFieldId, ControlBaseItemId.ToString());

            var parameterTemplateFieldId = new FieldId(new Guid("{7D24E54F-5C16-4314-90C9-6051AA1A7DA1}"));

            var fields = new List <Tuple <FieldId, string> >
            {
                new Tuple <FieldId, string>(parameterTemplateFieldId, parameterTemplateUri.ItemId.ToString()),
                new Tuple <FieldId, string>(DataSourceLocation, "PageSettings"),
                new Tuple <FieldId, string>(DataSourceTemplate, parameterTemplateUri.ItemId.ToString())
            };

            AppHost.Server.UpdateItem(parentUri, fields);

            AppHost.Windows.OpenTemplateDesigner(parameterTemplateUri);

            Notifications.RaiseItemAdded(this, new ItemVersionUri(parameterTemplateUri, LanguageManager.CurrentLanguage, Data.Version.Latest), parentUri);

            var activeContentTree = ActiveContext.ActiveContentTree;

            if (item is ItemTreeViewItem && activeContentTree != null)
            {
                var treeViewItem = activeContentTree.ContentTreeView.ExpandTo(parameterTemplateUri);
                if (treeViewItem != null)
                {
                    treeViewItem.IsSelected = true;
                }
            }
        }
Exemplo n.º 17
0
 /// <inheritdoc />
 protected override string FieldToString(FieldId field, RowVersion version)
 {
     return(field switch
     {
         FieldId.LastUpdate => "Day",
         FieldId.CountryRegion => "Country",
         FieldId.ProvinceState => "Province",
         FieldId.Admin2 => "County",
         FieldId.ContinentName => "Continent",
         FieldId.Population => "Population",
         FieldId.CombinedKey => "StatsName",
         _ => field.ToString()
     });
Exemplo n.º 18
0
        /// <summary>
        /// Configures the specified property info.
        /// </summary>
        /// <param name="propertyInfo">The property info.</param>
        /// <param name="config">The config.</param>
        public void Configure(PropertyInfo propertyInfo, SitecoreFieldConfiguration config)
        {
            config.FieldName = this.FieldName;

            if (config.FieldName.IsNullOrEmpty())
            {
                config.FieldName = propertyInfo.Name;
            }

            config.Setting   = this.Setting;
            config.CodeFirst = this.CodeFirst;

            if (FieldId.IsNotNullOrEmpty())
            {
                config.FieldId = new ID(this.FieldId);
            }

            config.FieldSource                 = this.FieldSource;
            config.FieldTitle                  = this.FieldTitle;
            config.FieldType                   = this.FieldType;
            config.CustomFieldType             = this.CustomFieldType;
            config.IsShared                    = this.IsShared;
            config.IsUnversioned               = this.IsUnversioned;
            config.SectionName                 = this.SectionName;
            config.Setting                     = this.Setting;
            config.FieldSortOrder              = this.FieldSortOrder;
            config.SectionSortOrder            = this.SectionSortOrder;
            config.ValidationErrorText         = this.ValidationErrorText;
            config.ValidationRegularExpression = this.ValidationRegularExpression;
            config.IsRequired                  = this.IsRequired;
            config.UrlOptions                  = this.UrlOptions;


            //code first configuration

            var fieldFieldValues = propertyInfo.GetCustomAttributes(typeof(SitecoreFieldFieldValueAttribute), true).Cast <SitecoreFieldFieldValueAttribute>();

            ////fix: fieldfieldvalues are not passed
            var interfaceFromProperty = propertyInfo.DeclaringType.GetInterfaces().FirstOrDefault(inter => inter.GetProperty(propertyInfo.Name) != null);

            if (interfaceFromProperty != null)
            {
                fieldFieldValues = interfaceFromProperty.GetProperty(propertyInfo.Name).GetCustomAttributes(typeof(SitecoreFieldFieldValueAttribute), true).Cast <SitecoreFieldFieldValueAttribute>();;
            }

            var ffvConfigs = fieldFieldValues.Select(x => x.Configure(propertyInfo, config));

            config.FieldValueConfigs = ffvConfigs.ToList();
            base.Configure(propertyInfo, config);
        }
Exemplo n.º 19
0
        /// <inheritdoc />
        protected override string FieldToString(FieldId field, RowVersion version)
        {
            return(field switch
            {
                FieldId.Confirmed => "Заражений",
                FieldId.LastUpdate => "Дата",
                FieldId.ProvinceState => "Регион",
                FieldId.Recovered => "Выздоровлений",
                FieldId.Deaths => "Смертей",
                FieldId.DeathsByDay => "Смертей за день",
                FieldId.ConfirmedByDay => "Заражений за день",
                FieldId.RecoveredByDay => "Выздоровлений за день",

                _ => field.ToString()
            });
Exemplo n.º 20
0
        private static void SetAccessor(AbcCode code, IMethod accessor, FieldId fieldId, int varProp)
        {
            if (accessor == null)
            {
                return;
            }
            var abcMethod = accessor.AbcMethod();

            if (abcMethod == null)
            {
                return;
            }
            int index = abcMethod.MethodInfoIndex;

            code.GetLocal(varProp);
            code.PushInt(index);
            code.SetField(fieldId);
        }
Exemplo n.º 21
0
        public Task <string> GetExceptionMessageAsync(TaggedObjectId exceptionObject)
        {
            if (_failedToFindThrowableDetailedMessageField)
            {
                return(null);
            }
            // TODO: this logic could be factored out into a "ReferenceTypeFieldValueRetriever" (find
            //       a better name...) class, and could also be used to directly show List<T> as
            //       array type in the watch window and similar fancy things.
            return(Task.Factory.StartNew(() =>
            {
                if (_throwableDetailedMessageFieldId == null)
                {
                    Process.ReferenceTypeManager.RefreshClassesWithSignatureAsync(ThrowableClassSignature)
                    .Await(DalvikProcess.VmTimeout);
                    var refType = Process.ReferenceTypeManager.FindBySignature(ThrowableClassSignature);
                    if (refType == null)
                    {
                        _failedToFindThrowableDetailedMessageField = true;
                        return null;
                    }
                    var fieldInfo = Debugger.ReferenceType.FieldsAsync(refType.Id).Await(DalvikProcess.VmTimeout)
                                    .FirstOrDefault(f => f.Name == ThrowableDetailMessageFieldName);
                    if (fieldInfo == null)
                    {
                        _failedToFindThrowableDetailedMessageField = true;
                        return null;
                    }
                    _throwableDetailedMessageFieldId = fieldInfo.Id;
                }

                var val = Debugger.ObjectReference.GetValuesAsync(exceptionObject.Object, new[] { _throwableDetailedMessageFieldId })
                          .Await(DalvikProcess.VmTimeout).First();

                var objectId = (ObjectId)val.ValueObject;
                if (objectId.IsNull)
                {
                    return null;
                }

                var ret = Debugger.StringReference.ValueAsync(objectId).Await(DalvikProcess.VmTimeout);
                return ret;
            }));
        }
Exemplo n.º 22
0
        public jvmtiError GetFieldName(jclass classHandle, FieldId fieldId, out string name, out string signature, out string genericSignature)
        {
            name             = null;
            signature        = null;
            genericSignature = null;

            IntPtr     namePtr;
            IntPtr     signaturePtr;
            IntPtr     genericPtr;
            jvmtiError error = RawInterface.GetFieldName(this, classHandle, fieldId, out namePtr, out signaturePtr, out genericPtr);

            if (error != jvmtiError.None)
            {
                return(error);
            }

            try
            {
                unsafe
                {
                    if (namePtr != IntPtr.Zero)
                    {
                        name = ModifiedUTF8Encoding.GetString((byte *)namePtr);
                    }
                    if (signaturePtr != IntPtr.Zero)
                    {
                        signature = ModifiedUTF8Encoding.GetString((byte *)signaturePtr);
                    }
                    if (genericPtr != IntPtr.Zero)
                    {
                        genericSignature = ModifiedUTF8Encoding.GetString((byte *)genericPtr);
                    }
                }
            }
            finally
            {
                Deallocate(namePtr);
                Deallocate(signaturePtr);
                Deallocate(genericPtr);
            }

            return(jvmtiError.None);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Configures the specified property info.
        /// </summary>
        /// <param name="propertyInfo">The property info.</param>
        /// <param name="config">The config.</param>
        public void Configure(PropertyInfo propertyInfo, SitecoreFieldConfiguration config)
        {
            config.FieldName = this.FieldName;

            if (config.FieldName.IsNullOrEmpty())
            {
                config.FieldName = propertyInfo.Name;
            }

            config.Setting   = this.Setting;
            config.CodeFirst = this.CodeFirst;

            if (FieldId.IsNotNullOrEmpty())
            {
                config.FieldId = new ID(this.FieldId);
            }

            config.FieldSource                 = this.FieldSource;
            config.FieldTitle                  = this.FieldTitle;
            config.FieldType                   = this.FieldType;
            config.CustomFieldType             = this.CustomFieldType;
            config.IsShared                    = this.IsShared;
            config.IsUnversioned               = this.IsUnversioned;
            config.SectionName                 = this.SectionName;
            config.Setting                     = this.Setting;
            config.FieldSortOrder              = this.FieldSortOrder;
            config.SectionSortOrder            = this.SectionSortOrder;
            config.ValidationErrorText         = this.ValidationErrorText;
            config.ValidationRegularExpression = this.ValidationRegularExpression;
            config.IsRequired                  = this.IsRequired;
            config.UrlOptions                  = this.UrlOptions;


            //code first configuration
            var fieldFieldValues = propertyInfo.GetCustomAttributes(typeof(SitecoreFieldFieldValueAttribute), true).Cast <SitecoreFieldFieldValueAttribute>();
            var ffvConfigs       = fieldFieldValues.Select(x => x.Configure(propertyInfo, config));

            config.FieldValueConfigs = ffvConfigs.ToList();

            base.Configure(propertyInfo, config);
        }
Exemplo n.º 24
0
 /// <summary>
 /// Default ctor
 /// </summary>
 protected BaseFieldEvent(JdwpPacket.DataReaderWriter reader)
     : base(reader)
 {
     refTypeTag = (DebuggerLib.Jdwp.TypeTag)reader.GetByte();
     switch (refTypeTag)
     {
         case DebuggerLib.Jdwp.TypeTag.Class:
             typeId = new ClassId(reader);
             break;
         case DebuggerLib.Jdwp.TypeTag.Interface:
             typeId = new InterfaceId(reader);
             break;
         case DebuggerLib.Jdwp.TypeTag.Array:
             typeId = new ArrayTypeId(reader);
             break;
         default:
             throw new ArgumentException("Unknown type tag " + (int)refTypeTag);
     }
     fieldId = new FieldId(reader);
     objectId = new TaggedObjectId(reader);
 }
Exemplo n.º 25
0
        public void TryGetDocumentationComments_returns_null_for_field_without_documentation()
        {
            // ARRANGE
            var cs = @"
	            using System;

	            public class Class1
	            {
                    public string Field1;
                }
            ";

            using var assembly = Compile(cs, out var xmlDocs);

            var id = new FieldId(new SimpleTypeId(NamespaceId.GlobalNamespace, "Class1"), "Field1");

            // ACT
            var sut  = new XmlDocsProvider(assembly, xmlDocs, NullLogger.Instance);
            var docs = sut.TryGetDocumentationComments(id);

            // ASSERT
            Assert.Null(docs);
        }
Exemplo n.º 26
0
 /// <summary>
 /// Returns information for each field in a reference type. Inherited fields are not included. The field list will include any synthetic 
 /// fields created by the compiler. Fields are returned in the order they occur in the class file.
 /// </summary>
 public Task<List<FieldInfo>> FieldsAsync(ReferenceTypeId id)
 {
     var conn = ConnectionOrError;
     var sizeInfo = conn.GetIdSizeInfo();
     var t = conn.SendAsync(JdwpPacket.CreateCommand(conn, Nr, 14, sizeInfo.ReferenceTypeIdSize, x => id.WriteTo(x.Data)));
     return t.ContinueWith(x => {
         x.ForwardException();
         var result = x.Result;
         result.ThrowOnError();
         var data = result.Data;
         var count = data.GetInt();
         var list = new List<FieldInfo>(count);
         for (var i = 0; i < count; i++ )
         {
             var fieldId = new FieldId(data);
             var name = data.GetString();
             var signature = data.GetString();
             var genericSignature = data.GetString();
             var accessFlags = data.GetInt();
             list.Add(new FieldInfo(fieldId, name, signature, genericSignature, accessFlags));
         }
         return list;
     });
 }
Exemplo n.º 27
0
        /// <summary>
        /// Default ctor
        /// </summary>
        protected BaseFieldEvent(JdwpPacket.DataReaderWriter reader)
            : base(reader)
        {
            refTypeTag = (DebuggerLib.Jdwp.TypeTag)reader.GetByte();
            switch (refTypeTag)
            {
            case DebuggerLib.Jdwp.TypeTag.Class:
                typeId = new ClassId(reader);
                break;

            case DebuggerLib.Jdwp.TypeTag.Interface:
                typeId = new InterfaceId(reader);
                break;

            case DebuggerLib.Jdwp.TypeTag.Array:
                typeId = new ArrayTypeId(reader);
                break;

            default:
                throw new ArgumentException("Unknown type tag " + (int)refTypeTag);
            }
            fieldId  = new FieldId(reader);
            objectId = new TaggedObjectId(reader);
        }
Exemplo n.º 28
0
        public jvmtiError GetClassFields(JniEnvironment nativeEnvironment, ReferenceTypeId declaringType, out FieldId[] fields)
        {
            fields = null;

            using (var @class = VirtualMachine.GetLocalReferenceForClass(nativeEnvironment, declaringType))
            {
                if ([email protected])
                    return jvmtiError.InvalidClass;

                int fieldsCount;
                IntPtr fieldsPtr;
                jvmtiError error = RawInterface.GetClassFields(this, @class.Value, out fieldsCount, out fieldsPtr);
                if (error != jvmtiError.None)
                    return error;

                try
                {
                    List<FieldId> fieldList = new List<FieldId>();
                    unsafe
                    {
                        jfieldID* fieldHandles = (jfieldID*)fieldsPtr;
                        for (int i = 0; i < fieldsCount; i++)
                        {
                            if (fieldHandles[i] == jfieldID.Null)
                                continue;

                            fieldList.Add(fieldHandles[i]);
                        }
                    }

                    fields = fieldList.ToArray();
                    return jvmtiError.None;
                }
                finally
                {
                    Deallocate(fieldsPtr);
                }
            }
        }
Exemplo n.º 29
0
        public jvmtiError GetFieldName(jclass classHandle, FieldId fieldId, out string name, out string signature, out string genericSignature)
        {
            name = null;
            signature = null;
            genericSignature = null;

            IntPtr namePtr;
            IntPtr signaturePtr;
            IntPtr genericPtr;
            jvmtiError error = RawInterface.GetFieldName(this, classHandle, fieldId, out namePtr, out signaturePtr, out genericPtr);
            if (error != jvmtiError.None)
                return error;

            try
            {
                unsafe
                {
                    if (namePtr != IntPtr.Zero)
                        name = ModifiedUTF8Encoding.GetString((byte*)namePtr);
                    if (signaturePtr != IntPtr.Zero)
                        signature = ModifiedUTF8Encoding.GetString((byte*)signaturePtr);
                    if (genericPtr != IntPtr.Zero)
                        genericSignature = ModifiedUTF8Encoding.GetString((byte*)genericPtr);
                }
            }
            finally
            {
                Deallocate(namePtr);
                Deallocate(signaturePtr);
                Deallocate(genericPtr);
            }

            return jvmtiError.None;
        }
Exemplo n.º 30
0
 public jvmtiError GetFieldModifiers(jclass classHandle, FieldId fieldId, out JvmAccessModifiers modifiers)
 {
     return RawInterface.GetFieldModifiers(this, classHandle, fieldId, out modifiers);
 }
Exemplo n.º 31
0
        public jvmtiError GetFieldDeclaringClass(JniEnvironment nativeEnvironment, jclass classHandle, FieldId fieldId, out TaggedReferenceTypeId declaringClass)
        {
            declaringClass = default(TaggedReferenceTypeId);

            jclass declaringClassHandle;
            jvmtiError error = RawInterface.GetFieldDeclaringClass(this, classHandle, fieldId, out declaringClassHandle);
            if (error != jvmtiError.None)
                return error;

            declaringClass = VirtualMachine.TrackLocalClassReference(declaringClassHandle, this, nativeEnvironment, true);
            return jvmtiError.None;
        }
Exemplo n.º 32
0
        public Error GetReferenceTypeValues(ReferenceTypeId referenceType, FieldId[] fields, out Value[] values)
        {
            values = null;

            try
            {
                JniEnvironment nativeEnvironment;
                JvmtiEnvironment environment;
                jvmtiError error = GetEnvironment(out environment, out nativeEnvironment);
                if (error != jvmtiError.None)
                    return GetStandardError(error);

                using (LocalClassReferenceHolder classHandle = VirtualMachine.GetLocalReferenceForClass(nativeEnvironment, referenceType))
                {
                    if (!classHandle.IsAlive)
                        return Error.InvalidClass;

                    Value[] valuesArray = new Value[fields.Length];
                    for (int i = 0; i < valuesArray.Length; i++)
                    {
                        string name;
                        string signature;
                        string genericSignature;

                        error = environment.GetFieldName(classHandle.Value, fields[i], out name, out signature, out genericSignature);
                        if (error != jvmtiError.None)
                            return GetStandardError(error);

                        switch (signature[0])
                        {
                        case 'Z':
                            valuesArray[i] = nativeEnvironment.GetStaticBooleanField(classHandle.Value, fields[i]);
                            break;

                        case 'B':
                            valuesArray[i] = nativeEnvironment.GetStaticByteField(classHandle.Value, fields[i]);
                            break;

                        case 'C':
                            valuesArray[i] = nativeEnvironment.GetStaticCharField(classHandle.Value, fields[i]);
                            break;

                        case 'D':
                            valuesArray[i] = nativeEnvironment.GetStaticDoubleField(classHandle.Value, fields[i]);
                            break;

                        case 'F':
                            valuesArray[i] = nativeEnvironment.GetStaticFloatField(classHandle.Value, fields[i]);
                            break;

                        case 'I':
                            valuesArray[i] = nativeEnvironment.GetStaticIntField(classHandle.Value, fields[i]);
                            break;

                        case 'J':
                            valuesArray[i] = nativeEnvironment.GetStaticLongField(classHandle.Value, fields[i]);
                            break;

                        case 'S':
                            valuesArray[i] = nativeEnvironment.GetStaticShortField(classHandle.Value, fields[i]);
                            break;

                        case 'V':
                            return Error.InvalidFieldid;

                        case '[':
                        case 'L':
                            jobject value = nativeEnvironment.GetStaticObjectField(classHandle.Value, fields[i]);
                            valuesArray[i] = VirtualMachine.TrackLocalObjectReference(value, environment, nativeEnvironment, true);
                            break;

                        default:
                            throw new FormatException();
                        }
                    }

                    values = valuesArray;
                    return Error.None;
                }
            }
            catch (Exception)
            {
                return Error.Internal;
            }
        }
Exemplo n.º 33
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public FieldOnlyModifier(ReferenceTypeId classId, FieldId fieldId)
     : base(9)
 {
     this.classId = classId;
     this.fieldId = fieldId;
 }
Exemplo n.º 34
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (StoryQuestId != 0UL)
            {
                hash ^= StoryQuestId.GetHashCode();
            }
            if (QuestNameId.Length != 0)
            {
                hash ^= QuestNameId.GetHashCode();
            }
            if (FieldId != 0UL)
            {
                hash ^= FieldId.GetHashCode();
            }
            if (RequiredConditionId != 0L)
            {
                hash ^= RequiredConditionId.GetHashCode();
            }
            if (SortBy != 0UL)
            {
                hash ^= SortBy.GetHashCode();
            }
            if (AreaSpotId != 0UL)
            {
                hash ^= AreaSpotId.GetHashCode();
            }
            if (ItemSetId != 0UL)
            {
                hash ^= ItemSetId.GetHashCode();
            }
            if (QuestGroupId != 0UL)
            {
                hash ^= QuestGroupId.GetHashCode();
            }
            if (FieldType != 0)
            {
                hash ^= FieldType.GetHashCode();
            }
            if (ScheduleId.Length != 0)
            {
                hash ^= ScheduleId.GetHashCode();
            }
            if (PlayCountLimit != 0L)
            {
                hash ^= PlayCountLimit.GetHashCode();
            }
            if (ChapterOpenAnimation != false)
            {
                hash ^= ChapterOpenAnimation.GetHashCode();
            }
            if (Difficulty != 0)
            {
                hash ^= Difficulty.GetHashCode();
            }
            if (WeekScheduleKeyword.Length != 0)
            {
                hash ^= WeekScheduleKeyword.GetHashCode();
            }
            if (Debug != false)
            {
                hash ^= Debug.GetHashCode();
            }
            if (DebugCategory != 0L)
            {
                hash ^= DebugCategory.GetHashCode();
            }
            if (RewardType != 0)
            {
                hash ^= RewardType.GetHashCode();
            }
            if (ShowcasedItemId != 0L)
            {
                hash ^= ShowcasedItemId.GetHashCode();
            }
            if (CharaQuestListItemId != 0L)
            {
                hash ^= CharaQuestListItemId.GetHashCode();
            }
            if (IsEvolutionQuest != false)
            {
                hash ^= IsEvolutionQuest.GetHashCode();
            }
            if (QuestType != 0)
            {
                hash ^= QuestType.GetHashCode();
            }
            if (IsSearchQuest != false)
            {
                hash ^= IsSearchQuest.GetHashCode();
            }
            if (NextQuestId != 0UL)
            {
                hash ^= NextQuestId.GetHashCode();
            }
            if (U24 != 0UL)
            {
                hash ^= U24.GetHashCode();
            }
            if (U25 != 0UL)
            {
                hash ^= U25.GetHashCode();
            }
            if (U26 != 0UL)
            {
                hash ^= U26.GetHashCode();
            }
            if (U27 != 0UL)
            {
                hash ^= U27.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 35
0
 public void FieldModification(Types.SuspendPolicy suspendPolicy, RequestId requestId, ThreadId thread, Types.Location location, TypeTag typeTag, ReferenceTypeId typeId, FieldId field, TaggedObjectId @object, Types.Value newValue)
 {
     throw new NotImplementedException();
 }
 public LayoutFileItemHandler()
 {
     TemplateId = IdManager.GetItemId(IdManager.SitecoreTemplatesSystemLayoutLayout);
     FieldId    = new FieldId(IdManager.GetItemId(IdManager.SitecoreTemplatesSystemLayoutLayoutDataPath).ToGuid());
 }
Exemplo n.º 37
0
 /// <summary>
 /// Default ctor
 /// </summary>
 internal DalvikField(DalvikReferenceType declaringType, FieldInfo info)
 {
     Id = info.Id;
     this.declaringType = declaringType;
     this.info = info;
 }
 public void FieldModification(Types.SuspendPolicy suspendPolicy, RequestId requestId, ThreadId thread, Types.Location location, TypeTag typeTag, ReferenceTypeId typeId, FieldId field, TaggedObjectId @object, Types.Value newValue)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 39
0
 public static EventRequestModifier FieldFilter(ReferenceTypeId declaringClass, FieldId field)
 {
     return new EventRequestModifier()
     {
         Kind = ModifierKind.FieldFilter,
         DeclaringClass = declaringClass,
         Field = field,
     };
 }
Exemplo n.º 40
0
 public void GoTo(FieldId fieldId, Int32 walkmeshId)
 {
     // TODO: Field script
     Console.WriteLine($"NotImplemented: {nameof(FieldService)}.{nameof(GoTo)}({nameof(fieldId)}: {fieldId}, {nameof(walkmeshId)}: {walkmeshId})");
 }
Exemplo n.º 41
0
        private void WriteFieldId(byte[] packet, int offset, FieldId fieldId)
        {
            if (!_fieldIdSize.HasValue)
                throw new InvalidOperationException();

            switch (_fieldIdSize.Value)
            {
            case 2:
                WriteInt16(packet, offset, (short)fieldId.Handle);
                break;

            case 4:
                WriteInt32(packet, offset, (int)fieldId.Handle);
                break;

            case 8:
                WriteInt64(packet, offset, fieldId.Handle);
                break;

            default:
                throw new NotImplementedException();
            }
        }
Exemplo n.º 42
0
        public Task<string> GetExceptionMessageAsync(TaggedObjectId exceptionObject)
        {
            if (_failedToFindThrowableDetailedMessageField)
                return null;
            // TODO: this logic could be factored out into a "ReferenceTypeFieldValueRetriever" (find
            //       a better name...) class, and could also be used to directly show List<T> as
            //       array type in the watch window and similar fancy things.
            return Task.Factory.StartNew(() =>
            {
                if (_throwableDetailedMessageFieldId == null)
                {
                    Process.ReferenceTypeManager.RefreshClassesWithSignatureAsync(ThrowableClassSignature)
                                                .Await(DalvikProcess.VmTimeout);
                    var refType = Process.ReferenceTypeManager.FindBySignature(ThrowableClassSignature);
                    if (refType == null)
                    {
                        _failedToFindThrowableDetailedMessageField = true;
                        return null;
                    }
                    var fieldInfo = Debugger.ReferenceType.FieldsAsync(refType.Id).Await(DalvikProcess.VmTimeout)
                                                          .FirstOrDefault(f => f.Name == ThrowableDetailMessageFieldName);
                    if (fieldInfo == null)
                    {
                        _failedToFindThrowableDetailedMessageField = true;
                        return null;
                    }
                    _throwableDetailedMessageFieldId = fieldInfo.Id;
                }

                var val = Debugger.ObjectReference.GetValuesAsync(exceptionObject.Object, new[] { _throwableDetailedMessageFieldId })
                                                  .Await(DalvikProcess.VmTimeout).First();

                var objectId = (ObjectId)val.ValueObject;
                if(objectId.IsNull)
                    return null;

                var ret = Debugger.StringReference.ValueAsync(objectId).Await(DalvikProcess.VmTimeout);
                return ret;
            });
        }
Exemplo n.º 43
0
        public Error GetReferenceTypeValues(out Value[] values, ReferenceTypeId referenceType, FieldId[] fields)
        {
            byte[] packet = new byte[HeaderSize + ReferenceTypeIdSize + sizeof(int) + (fields.Length * FieldIdSize)];
            int id = GetMessageId();
            SerializeHeader(packet, id, ReferenceTypeCommand.GetValues);
            WriteReferenceTypeId(packet, HeaderSize, referenceType);
            WriteInt32(packet, HeaderSize + ReferenceTypeIdSize, fields.Length);
            for (int i = 0; i < fields.Length; i++)
            {
                WriteFieldId(packet, HeaderSize + ReferenceTypeIdSize + sizeof(int) + (i * FieldIdSize), fields[i]);
            }

            byte[] response = SendPacket(id, packet);
            Error errorCode = ReadErrorCode(response);
            if (errorCode != Error.None)
            {
                values = null;
                return errorCode;
            }

            int offset = HeaderSize;
            int valueCount = ReadInt32(response, ref offset);
            values = new Value[valueCount];
            for (int i = 0; i < valueCount; i++)
            {
                values[i] = ReadValue(response, ref offset);
            }

            return Error.None;
        }
Exemplo n.º 44
0
 internal Field(VirtualMachine virtualMachine, ReferenceType declaringType, string name, string signature, string genericSignature, AccessModifiers modifiers, FieldId fieldId)
     : base(virtualMachine, declaringType, name, signature, genericSignature, modifiers)
 {
     Contract.Requires(virtualMachine != null);
     _fieldId = fieldId;
 }
 public CshtmlFileItemHandler()
 {
     TemplateId = new ItemId(new Guid("{99F8905D-4A87-4EB8-9F8B-A9BEBFB3ADD6}"));
     FieldId    = new FieldId(new Guid("{51B435BC-F7B9-478A-9C51-52916AF96FF5}"));
 }
Exemplo n.º 46
0
        public IDictionary<IField, IValue> GetValues(IEnumerable<IField> fields)
        {
            IField[] fieldsArray = fields.ToArray();

            FieldId[] fieldIds = new FieldId[fieldsArray.Length];
            // verify each field comes from this VM
            for (int i = 0; i < fieldsArray.Length; i++)
            {
                Field field = fieldsArray[i] as Field;
                if (field == null)
                    throw new VirtualMachineMismatchException();

                fieldIds[i] = field.FieldId;
            }

            Types.Value[] values;
            DebugErrorHandler.ThrowOnFailure(VirtualMachine.ProtocolService.GetObjectValues(out values, ObjectId, fieldIds));

            Dictionary<IField, IValue> result = new Dictionary<IField, IValue>();
            for (int i = 0; i < fieldIds.Length; i++)
                result[fieldsArray[i]] = VirtualMachine.GetMirrorOf(values[i]);

            return result;
        }
Exemplo n.º 47
0
 public void PrepareGoTo(FieldId fieldId)
 {
     // TODO: Field script
     Console.WriteLine($"NotImplemented: {nameof(FieldService)}.{nameof(PrepareGoTo)}({nameof(fieldId)}: {fieldId})");
 }
Exemplo n.º 48
0
 public Error SetClassValues(ClassId @class, FieldId[] fields, Value[] values)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 49
0
 public override int GetHashCode()
 {
     return(FieldId.GetHashCode());
 }
Exemplo n.º 50
0
 public Error SetObjectValues(ObjectId @object, FieldId[] fields, Value[] values)
 {
     throw new NotImplementedException();
 }