private static void CheckMetadataChanges(string metadataSet, string entitySet, string entityKind, Entity entity,
                                                 DataLoaderParams Params, MetadataKind metadataKind)
        {
            var context = new TableContext(s_account.TableEndpoint.ToString(), s_account.Credentials, Params)
            {
                RetryPolicy =
                    RetryPolicies.RetryExponential(RetryPolicies.DefaultClientRetryCount,
                                                   RetryPolicies.DefaultClientBackoff)
            };

            string             query   = string.Format(s_metadataEntityQueryTemplate, metadataSet, entitySet, entityKind);
            List <TableEntity> results = context.Execute <TableEntity>(new Uri(query, UriKind.Relative)).ToList();

            if (results.Count == 1)
            {
                var exceprionColumns = new[]
                {
                    DataLoaderConstants.PropNameEntityId,
                    DataLoaderConstants.PropNameLastUpdateDate
                };
                string differences = results[0].FindDifferences(entity, exceprionColumns);
                if (differences != null)
                {
                    throw new MetadataChangedException(entitySet, differences);
                }
            }
            else if (results.Count > 1)
            {
                throw new DuplicateEntityException(query);
            }
            else if (results.Count == 0)
            {
                throw new MetadataNotFoundException(entitySet, metadataKind);
            }
        }
Beispiel #2
0
 internal Metadata(MetadataKind kind, string name, int id, string typeName, int version, string serializerTypeName, int serializerVersion, ushort customFlags)
 {
     this.Kind               = kind;
     this.Name               = name;
     this.Id                 = id;
     this.TypeName           = typeName;
     this.Version            = version;
     this.SerializerTypeName = serializerTypeName;
     this.SerializerVersion  = serializerVersion;
     this.CustomFlags        = customFlags;
 }
        public static void Project(TypeDefinition type)
        {
            TypeDefinitionTreatment       treatment         = TypeDefinitionTreatment.None;
            MetadataKind                  metadata_kind     = type.Module.MetadataKind;
            Collection <MethodDefinition> redirectedMethods = null;
            Collection <KeyValuePair <InterfaceImplementation, InterfaceImplementation> > redirectedInterfaces = null;

            if (type.IsWindowsRuntime)
            {
                if (metadata_kind == MetadataKind.WindowsMetadata)
                {
                    treatment = GetWellKnownTypeDefinitionTreatment(type);
                    if (treatment != TypeDefinitionTreatment.None)
                    {
                        ApplyProjection(type, new TypeDefinitionProjection(type, treatment, redirectedMethods, redirectedInterfaces));
                        return;
                    }

                    TypeReference base_type = type.BaseType;
                    if (base_type != null && IsAttribute(base_type))
                    {
                        treatment = TypeDefinitionTreatment.NormalAttribute;
                    }
                    else
                    {
                        treatment = GenerateRedirectionInformation(type, out redirectedMethods, out redirectedInterfaces);
                    }
                }
                else if (metadata_kind == MetadataKind.ManagedWindowsMetadata && NeedsWindowsRuntimePrefix(type))
                {
                    treatment = TypeDefinitionTreatment.PrefixWindowsRuntimeName;
                }

                if (treatment == TypeDefinitionTreatment.PrefixWindowsRuntimeName || treatment == TypeDefinitionTreatment.NormalType)
                {
                    if (!type.IsInterface && HasAttribute(type, "Windows.UI.Xaml", "TreatAsAbstractComposableClassAttribute"))
                    {
                        treatment |= TypeDefinitionTreatment.Abstract;
                    }
                }
            }
            else if (metadata_kind == MetadataKind.ManagedWindowsMetadata && IsClrImplementationType(type))
            {
                treatment = TypeDefinitionTreatment.UnmangleWindowsRuntimeName;
            }

            if (treatment != TypeDefinitionTreatment.None)
            {
                ApplyProjection(type, new TypeDefinitionProjection(type, treatment, redirectedMethods, redirectedInterfaces));
            }
        }
        public string ShouldReturnMetadata(string path, MetadataKind properties)
        {
            IMetadataElement element;

            Assert.That(TryGetMetadata(path, out element), Is.True);
            Assert.That(element, Is.Not.Null);

            var ignoredFeatures = new[] { typeof(EntityIdentityFeature), typeof(ElementMappingFeature), typeof(EntityRelationContainmentFeature) };
            element.Dump(properties, ignoredFeatures);

            Debug.WriteLine((string)element.Serialize(properties, ignoredFeatures));

            return element.Serialize(properties, ignoredFeatures);
        }
Beispiel #5
0
        public string ShouldReturnMetadata(string path, MetadataKind properties)
        {
            IMetadataElement element;

            Assert.That(TryGetMetadata(path, out element), Is.True);
            Assert.That(element, Is.Not.Null);

            var ignoredFeatures = new[] { typeof(EntityIdentityFeature), typeof(ElementMappingFeature), typeof(EntityRelationContainmentFeature) };

            element.Dump(properties, ignoredFeatures);

            Debug.WriteLine((string)element.Serialize(properties, ignoredFeatures));

            return(element.Serialize(properties, ignoredFeatures));
        }
        public static void Project(TypeDefinition type)
        {
            TypeDefinitionTreatment typeDefinitionTreatment = TypeDefinitionTreatment.None;
            MetadataKind            metadataKind            = type.Module.MetadataKind;

            if (type.IsWindowsRuntime)
            {
                switch (metadataKind)
                {
                case MetadataKind.WindowsMetadata:
                {
                    typeDefinitionTreatment = GetWellKnownTypeDefinitionTreatment(type);
                    if (typeDefinitionTreatment != 0)
                    {
                        ApplyProjection(type, new TypeDefinitionProjection(type, typeDefinitionTreatment));
                        return;
                    }
                    TypeReference baseType = type.BaseType;
                    typeDefinitionTreatment = ((baseType == null || !IsAttribute(baseType)) ? TypeDefinitionTreatment.NormalType : TypeDefinitionTreatment.NormalAttribute);
                    break;
                }

                case MetadataKind.ManagedWindowsMetadata:
                    if (NeedsWindowsRuntimePrefix(type))
                    {
                        typeDefinitionTreatment = TypeDefinitionTreatment.PrefixWindowsRuntimeName;
                    }
                    break;
                }
                if ((typeDefinitionTreatment == TypeDefinitionTreatment.PrefixWindowsRuntimeName || typeDefinitionTreatment == TypeDefinitionTreatment.NormalType) && !type.IsInterface && HasAttribute(type, "Windows.UI.Xaml", "TreatAsAbstractComposableClassAttribute"))
                {
                    typeDefinitionTreatment |= TypeDefinitionTreatment.Abstract;
                }
            }
            else if (metadataKind == MetadataKind.ManagedWindowsMetadata && IsClrImplementationType(type))
            {
                typeDefinitionTreatment = TypeDefinitionTreatment.UnmangleWindowsRuntimeName;
            }
            if (typeDefinitionTreatment != 0)
            {
                ApplyProjection(type, new TypeDefinitionProjection(type, typeDefinitionTreatment));
            }
        }
        private static HashSet<string> ResolvePropertyNames(MetadataKind metadata)
        {
            var propertyNames = metadata.ToString().Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries);

            return propertyNames.Length > 0 ? new HashSet<string>(MainProperties.Intersect(propertyNames)) : MainProperties;
        }
 public MetadataNotFoundException(String entitySetName, MetadataKind metadataKind)
     : base(ConstructMessage(entitySetName, metadataKind))
 {
 }
        private static string SerializeAndDump(TMetadataElement element, MetadataKind metadata)
        {
            element.Dump(metadata);

            return(element.Serialize(metadata));
        }
Beispiel #10
0
        internal BlobHeap(MemoryBlock block, MetadataKind metadataKind)
        {
            _lazyVirtualHeap = null;
            Block            = block;

            if (s_virtualValues == null && metadataKind != MetadataKind.Ecma335)
            {
                var blobs = new byte[(int)BlobHandle.VirtualIndex.Count][];

                blobs[(int)BlobHandle.VirtualIndex.ContractPublicKeyToken] = new byte[]
                {
                    0xB0, 0x3F, 0x5F, 0x7F, 0x11, 0xD5, 0x0A, 0x3A
                };

                blobs[(int)BlobHandle.VirtualIndex.ContractPublicKey] = new byte[]
                {
                    0x00, 0x24, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, 0x06, 0x02, 0x00, 0x00,
                    0x00, 0x24, 0x00, 0x00, 0x52, 0x53, 0x41, 0x31, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00,
                    0x07, 0xD1, 0xFA, 0x57, 0xC4, 0xAE, 0xD9, 0xF0, 0xA3, 0x2E, 0x84, 0xAA, 0x0F, 0xAE, 0xFD, 0x0D,
                    0xE9, 0xE8, 0xFD, 0x6A, 0xEC, 0x8F, 0x87, 0xFB, 0x03, 0x76, 0x6C, 0x83, 0x4C, 0x99, 0x92, 0x1E,
                    0xB2, 0x3B, 0xE7, 0x9A, 0xD9, 0xD5, 0xDC, 0xC1, 0xDD, 0x9A, 0xD2, 0x36, 0x13, 0x21, 0x02, 0x90,
                    0x0B, 0x72, 0x3C, 0xF9, 0x80, 0x95, 0x7F, 0xC4, 0xE1, 0x77, 0x10, 0x8F, 0xC6, 0x07, 0x77, 0x4F,
                    0x29, 0xE8, 0x32, 0x0E, 0x92, 0xEA, 0x05, 0xEC, 0xE4, 0xE8, 0x21, 0xC0, 0xA5, 0xEF, 0xE8, 0xF1,
                    0x64, 0x5C, 0x4C, 0x0C, 0x93, 0xC1, 0xAB, 0x99, 0x28, 0x5D, 0x62, 0x2C, 0xAA, 0x65, 0x2C, 0x1D,
                    0xFA, 0xD6, 0x3D, 0x74, 0x5D, 0x6F, 0x2D, 0xE5, 0xF1, 0x7E, 0x5E, 0xAF, 0x0F, 0xC4, 0x96, 0x3D,
                    0x26, 0x1C, 0x8A, 0x12, 0x43, 0x65, 0x18, 0x20, 0x6D, 0xC0, 0x93, 0x34, 0x4D, 0x5A, 0xD2, 0x93
                };

                blobs[(int)BlobHandle.VirtualIndex.AttributeUsage_AllowSingle] = new byte[]
                {
                    // preamble:
                    0x01, 0x00,
                    // target (template parameter):
                    0x00, 0x00, 0x00, 0x00,
                    // named arg count:
                    0x01, 0x00,
                    // SERIALIZATION_TYPE_PROPERTY
                    0x54,
                    // ELEMENT_TYPE_BOOLEAN
                    0x02,
                    // "AllowMultiple".Length
                    0x0D,
                    // "AllowMultiple"
                    0x41, 0x6C, 0x6C, 0x6F, 0x77, 0x4D, 0x75, 0x6C, 0x74, 0x69, 0x70, 0x6C, 0x65,
                    // false
                    0x00
                };

                blobs[(int)BlobHandle.VirtualIndex.AttributeUsage_AllowMultiple] = new byte[]
                {
                    // preamble:
                    0x01, 0x00,
                    // target (template parameter):
                    0x00, 0x00, 0x00, 0x00,
                    // named arg count:
                    0x01, 0x00,
                    // SERIALIZATION_TYPE_PROPERTY
                    0x54,
                    // ELEMENT_TYPE_BOOLEAN
                    0x02,
                    // "AllowMultiple".Length
                    0x0D,
                    // "AllowMultiple"
                    0x41, 0x6C, 0x6C, 0x6F, 0x77, 0x4D, 0x75, 0x6C, 0x74, 0x69, 0x70, 0x6C, 0x65,
                    // true
                    0x01
                };

                s_virtualValues = blobs;
            }
        }
Beispiel #11
0
 internal BlobHeap(MemoryBlock block, MetadataKind metadataKind)
 {
     Block = block;
 }
Beispiel #12
0
        internal StringStreamReader(MemoryBlock block, MetadataKind metadataKind)
        {
            if (s_virtualValues == null && metadataKind != MetadataKind.Ecma335)
            {
                // Note:
                // Virtual values shall not contain surrogates, otherwise StartsWith might be inconsistent 
                // when comparing to a text that ends with a high surrogate.

                var values = new string[(int)StringHandle.VirtualIndex.Count];
                values[(int)StringHandle.VirtualIndex.System_Runtime_WindowsRuntime] = "System.Runtime.WindowsRuntime";
                values[(int)StringHandle.VirtualIndex.System_Runtime] = "System.Runtime";
                values[(int)StringHandle.VirtualIndex.System_ObjectModel] = "System.ObjectModel";
                values[(int)StringHandle.VirtualIndex.System_Runtime_WindowsRuntime_UI_Xaml] = "System.Runtime.WindowsRuntime.UI.Xaml";
                values[(int)StringHandle.VirtualIndex.System_Runtime_InteropServices_WindowsRuntime] = "System.Runtime.InteropServices.WindowsRuntime";
                values[(int)StringHandle.VirtualIndex.System_Numerics_Vectors] = "System.Numerics.Vectors";

                values[(int)StringHandle.VirtualIndex.Dispose] = "Dispose";

                values[(int)StringHandle.VirtualIndex.AttributeTargets] = "AttributeTargets";
                values[(int)StringHandle.VirtualIndex.AttributeUsageAttribute] = "AttributeUsageAttribute";
                values[(int)StringHandle.VirtualIndex.Color] = "Color";
                values[(int)StringHandle.VirtualIndex.CornerRadius] = "CornerRadius";
                values[(int)StringHandle.VirtualIndex.DateTimeOffset] = "DateTimeOffset";
                values[(int)StringHandle.VirtualIndex.Duration] = "Duration";
                values[(int)StringHandle.VirtualIndex.DurationType] = "DurationType";
                values[(int)StringHandle.VirtualIndex.EventHandler1] = "EventHandler`1";
                values[(int)StringHandle.VirtualIndex.EventRegistrationToken] = "EventRegistrationToken";
                values[(int)StringHandle.VirtualIndex.Exception] = "Exception";
                values[(int)StringHandle.VirtualIndex.GeneratorPosition] = "GeneratorPosition";
                values[(int)StringHandle.VirtualIndex.GridLength] = "GridLength";
                values[(int)StringHandle.VirtualIndex.GridUnitType] = "GridUnitType";
                values[(int)StringHandle.VirtualIndex.ICommand] = "ICommand";
                values[(int)StringHandle.VirtualIndex.IDictionary2] = "IDictionary`2";
                values[(int)StringHandle.VirtualIndex.IDisposable] = "IDisposable";
                values[(int)StringHandle.VirtualIndex.IEnumerable] = "IEnumerable";
                values[(int)StringHandle.VirtualIndex.IEnumerable1] = "IEnumerable`1";
                values[(int)StringHandle.VirtualIndex.IList] = "IList";
                values[(int)StringHandle.VirtualIndex.IList1] = "IList`1";
                values[(int)StringHandle.VirtualIndex.INotifyCollectionChanged] = "INotifyCollectionChanged";
                values[(int)StringHandle.VirtualIndex.INotifyPropertyChanged] = "INotifyPropertyChanged";
                values[(int)StringHandle.VirtualIndex.IReadOnlyDictionary2] = "IReadOnlyDictionary`2";
                values[(int)StringHandle.VirtualIndex.IReadOnlyList1] = "IReadOnlyList`1";
                values[(int)StringHandle.VirtualIndex.KeyTime] = "KeyTime";
                values[(int)StringHandle.VirtualIndex.KeyValuePair2] = "KeyValuePair`2";
                values[(int)StringHandle.VirtualIndex.Matrix] = "Matrix";
                values[(int)StringHandle.VirtualIndex.Matrix3D] = "Matrix3D";
                values[(int)StringHandle.VirtualIndex.Matrix3x2] = "Matrix3x2";
                values[(int)StringHandle.VirtualIndex.Matrix4x4] = "Matrix4x4";
                values[(int)StringHandle.VirtualIndex.NotifyCollectionChangedAction] = "NotifyCollectionChangedAction";
                values[(int)StringHandle.VirtualIndex.NotifyCollectionChangedEventArgs] = "NotifyCollectionChangedEventArgs";
                values[(int)StringHandle.VirtualIndex.NotifyCollectionChangedEventHandler] = "NotifyCollectionChangedEventHandler";
                values[(int)StringHandle.VirtualIndex.Nullable1] = "Nullable`1";
                values[(int)StringHandle.VirtualIndex.Plane] = "Plane";
                values[(int)StringHandle.VirtualIndex.Point] = "Point";
                values[(int)StringHandle.VirtualIndex.PropertyChangedEventArgs] = "PropertyChangedEventArgs";
                values[(int)StringHandle.VirtualIndex.PropertyChangedEventHandler] = "PropertyChangedEventHandler";
                values[(int)StringHandle.VirtualIndex.Quaternion] = "Quaternion";
                values[(int)StringHandle.VirtualIndex.Rect] = "Rect";
                values[(int)StringHandle.VirtualIndex.RepeatBehavior] = "RepeatBehavior";
                values[(int)StringHandle.VirtualIndex.RepeatBehaviorType] = "RepeatBehaviorType";
                values[(int)StringHandle.VirtualIndex.Size] = "Size";
                values[(int)StringHandle.VirtualIndex.System] = "System";
                values[(int)StringHandle.VirtualIndex.System_Collections] = "System.Collections";
                values[(int)StringHandle.VirtualIndex.System_Collections_Generic] = "System.Collections.Generic";
                values[(int)StringHandle.VirtualIndex.System_Collections_Specialized] = "System.Collections.Specialized";
                values[(int)StringHandle.VirtualIndex.System_ComponentModel] = "System.ComponentModel";
                values[(int)StringHandle.VirtualIndex.System_Numerics] = "System.Numerics";
                values[(int)StringHandle.VirtualIndex.System_Windows_Input] = "System.Windows.Input";
                values[(int)StringHandle.VirtualIndex.Thickness] = "Thickness";
                values[(int)StringHandle.VirtualIndex.TimeSpan] = "TimeSpan";
                values[(int)StringHandle.VirtualIndex.Type] = "Type";
                values[(int)StringHandle.VirtualIndex.Uri] = "Uri";
                values[(int)StringHandle.VirtualIndex.Vector2] = "Vector2";
                values[(int)StringHandle.VirtualIndex.Vector3] = "Vector3";
                values[(int)StringHandle.VirtualIndex.Vector4] = "Vector4";
                values[(int)StringHandle.VirtualIndex.Windows_Foundation] = "Windows.Foundation";
                values[(int)StringHandle.VirtualIndex.Windows_UI] = "Windows.UI";
                values[(int)StringHandle.VirtualIndex.Windows_UI_Xaml] = "Windows.UI.Xaml";
                values[(int)StringHandle.VirtualIndex.Windows_UI_Xaml_Controls_Primitives] = "Windows.UI.Xaml.Controls.Primitives";
                values[(int)StringHandle.VirtualIndex.Windows_UI_Xaml_Media] = "Windows.UI.Xaml.Media";
                values[(int)StringHandle.VirtualIndex.Windows_UI_Xaml_Media_Animation] = "Windows.UI.Xaml.Media.Animation";
                values[(int)StringHandle.VirtualIndex.Windows_UI_Xaml_Media_Media3D] = "Windows.UI.Xaml.Media.Media3D";

                s_virtualValues = values;
                AssertFilled();
            }

            this.Block = TrimEnd(block);
        }
Beispiel #13
0
 public MetadataNotFoundException(String entitySetName, MetadataKind metadataKind)
     : base(ConstructMessage(entitySetName, metadataKind))
 {
 }
Beispiel #14
0
        private static string ConstructMessage(String entitySetName, MetadataKind metadataKind)
        {
            string mess = metadataKind + " metadata for " + entitySetName + " was not found in the storage.";

            return(mess);
        }
 private static string ConstructMessage(String entitySetName, MetadataKind metadataKind)
 {
     string mess = metadataKind + " metadata for " + entitySetName + " was not found in the storage.";
     return mess;
 }
        private static void CheckMetadataChanges(string metadataSet, string entitySet, string entityKind, Entity entity,
                                                 DataLoaderParams Params, MetadataKind metadataKind)
        {
            var context = new TableContext(s_account.TableEndpoint.ToString(), s_account.Credentials, Params)
                              {
                                  RetryPolicy =
                                      RetryPolicies.RetryExponential(RetryPolicies.DefaultClientRetryCount,
                                                                     RetryPolicies.DefaultClientBackoff)
                              };

            string query = string.Format(s_metadataEntityQueryTemplate, metadataSet, entitySet, entityKind);
            List<TableEntity> results = context.Execute<TableEntity>(new Uri(query, UriKind.Relative)).ToList();
            if (results.Count == 1)
            {
                var exceprionColumns = new[]
                                           {
                                               DataLoaderConstants.PropNameEntityId,
                                               DataLoaderConstants.PropNameLastUpdateDate
                                           };
                string differences = results[0].FindDifferences(entity, exceprionColumns);
                if (differences != null)
                    throw new MetadataChangedException(entitySet, differences);
            }
            else if (results.Count > 1)
            {
                throw new DuplicateEntityException(query);
            }
            else if (results.Count == 0)
            {
                throw new MetadataNotFoundException(entitySet, metadataKind);
            }
        }
Beispiel #17
0
        internal BlobHeap(MemoryBlock block, MetadataKind metadataKind)
        {
            _lazyVirtualHeap = null;
            Block = block;

            if (s_virtualValues == null && metadataKind != MetadataKind.Ecma335)
            {
                var blobs = new byte[(int)BlobHandle.VirtualIndex.Count][];

                blobs[(int)BlobHandle.VirtualIndex.ContractPublicKeyToken] = new byte[]
                {
                    0xB0, 0x3F, 0x5F, 0x7F, 0x11, 0xD5, 0x0A, 0x3A
                };

                blobs[(int)BlobHandle.VirtualIndex.ContractPublicKey] = new byte[]
                {
                    0x00, 0x24, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, 0x06, 0x02, 0x00, 0x00,
                    0x00, 0x24, 0x00, 0x00, 0x52, 0x53, 0x41, 0x31, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00,
                    0x07, 0xD1, 0xFA, 0x57, 0xC4, 0xAE, 0xD9, 0xF0, 0xA3, 0x2E, 0x84, 0xAA, 0x0F, 0xAE, 0xFD, 0x0D,
                    0xE9, 0xE8, 0xFD, 0x6A, 0xEC, 0x8F, 0x87, 0xFB, 0x03, 0x76, 0x6C, 0x83, 0x4C, 0x99, 0x92, 0x1E,
                    0xB2, 0x3B, 0xE7, 0x9A, 0xD9, 0xD5, 0xDC, 0xC1, 0xDD, 0x9A, 0xD2, 0x36, 0x13, 0x21, 0x02, 0x90,
                    0x0B, 0x72, 0x3C, 0xF9, 0x80, 0x95, 0x7F, 0xC4, 0xE1, 0x77, 0x10, 0x8F, 0xC6, 0x07, 0x77, 0x4F,
                    0x29, 0xE8, 0x32, 0x0E, 0x92, 0xEA, 0x05, 0xEC, 0xE4, 0xE8, 0x21, 0xC0, 0xA5, 0xEF, 0xE8, 0xF1,
                    0x64, 0x5C, 0x4C, 0x0C, 0x93, 0xC1, 0xAB, 0x99, 0x28, 0x5D, 0x62, 0x2C, 0xAA, 0x65, 0x2C, 0x1D,
                    0xFA, 0xD6, 0x3D, 0x74, 0x5D, 0x6F, 0x2D, 0xE5, 0xF1, 0x7E, 0x5E, 0xAF, 0x0F, 0xC4, 0x96, 0x3D,
                    0x26, 0x1C, 0x8A, 0x12, 0x43, 0x65, 0x18, 0x20, 0x6D, 0xC0, 0x93, 0x34, 0x4D, 0x5A, 0xD2, 0x93
                };

                blobs[(int)BlobHandle.VirtualIndex.AttributeUsage_AllowSingle] = new byte[]
                {
                    // preamble:
                    0x01, 0x00,
                    // target (template parameter):
                    0x00, 0x00, 0x00, 0x00,
                    // named arg count:
                    0x01, 0x00,
                    // SERIALIZATION_TYPE_PROPERTY
                    0x54,
                    // ELEMENT_TYPE_BOOLEAN
                    0x02,
                    // "AllowMultiple".Length
                    0x0D,
                    // "AllowMultiple"
                    0x41, 0x6C, 0x6C, 0x6F, 0x77, 0x4D, 0x75, 0x6C, 0x74, 0x69, 0x70, 0x6C, 0x65,
                    // false
                    0x00
                };

                blobs[(int)BlobHandle.VirtualIndex.AttributeUsage_AllowMultiple] = new byte[]
                {
                    // preamble:
                    0x01, 0x00,
                    // target (template parameter):
                    0x00, 0x00, 0x00, 0x00,
                    // named arg count:
                    0x01, 0x00,
                    // SERIALIZATION_TYPE_PROPERTY
                    0x54,
                    // ELEMENT_TYPE_BOOLEAN
                    0x02,
                    // "AllowMultiple".Length
                    0x0D,
                    // "AllowMultiple"
                    0x41, 0x6C, 0x6C, 0x6F, 0x77, 0x4D, 0x75, 0x6C, 0x74, 0x69, 0x70, 0x6C, 0x65,
                    // true
                    0x01
                };

                s_virtualValues = blobs;
            }
        }
Beispiel #18
0
        internal AssemblyRefTableReader(
            int numberOfRows,
            int stringHeapRefSize,
            int blobHeapRefSize,
            MemoryBlock containingBlock,
            int containingBlockOffset,
            MetadataKind metadataKind)
        {
            this.NumberOfNonVirtualRows = numberOfRows;
            this.NumberOfVirtualRows = (metadataKind == MetadataKind.Ecma335) ? 0 : (int)AssemblyReferenceHandle.VirtualIndex.Count;

            _IsStringHeapRefSizeSmall = stringHeapRefSize == 2;
            _IsBlobHeapRefSizeSmall = blobHeapRefSize == 2;
            _MajorVersionOffset = 0;
            _MinorVersionOffset = _MajorVersionOffset + sizeof(UInt16);
            _BuildNumberOffset = _MinorVersionOffset + sizeof(UInt16);
            _RevisionNumberOffset = _BuildNumberOffset + sizeof(UInt16);
            _FlagsOffset = _RevisionNumberOffset + sizeof(UInt16);
            _PublicKeyOrTokenOffset = _FlagsOffset + sizeof(UInt32);
            _NameOffset = _PublicKeyOrTokenOffset + blobHeapRefSize;
            _CultureOffset = _NameOffset + stringHeapRefSize;
            _HashValueOffset = _CultureOffset + stringHeapRefSize;
            this.RowSize = _HashValueOffset + blobHeapRefSize;
            this.Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, this.RowSize * numberOfRows);
        }
Beispiel #19
0
 public static void Dump(this IMetadataElement element, MetadataKind metadata, Type[] ignoredFeatures = null)
 {
     Debug.WriteLine(element.ToJson(true, ResolvePropertyNames(metadata), ignoredFeatures));
 }
Beispiel #20
0
 /// <summary>Gets or sets Metadata (as a value) for this instruction</summary>
 /// <param name="kindKey">Metadata kind to get</param>
 /// <returns>Metadata for the kind or <see langword="null"/> if not present</returns>
 public MetadataAsValue this[MetadataKind kindKey]
 {
     get => FromHandle <MetadataAsValue>(LLVMGetMetadata(ValueHandle, ( uint )kindKey));
Beispiel #21
0
 public static string Serialize(this IMetadataElement element, MetadataKind metadata, Type[] ignoredFeatures = null)
 {
     return(element.ToJson(false, ResolvePropertyNames(metadata), ignoredFeatures).Replace("\"", "'"));
 }
Beispiel #22
0
        internal StringStreamReader(MemoryBlock block, MetadataKind metadataKind)
        {
            if (s_virtualValues == null && metadataKind != MetadataKind.Ecma335)
            {
                // Note:
                // Virtual values shall not contain surrogates, otherwise StartsWith might be inconsistent
                // when comparing to a text that ends with a high surrogate.

                var values = new string[(int)StringHandle.VirtualIndex.Count];
                values[(int)StringHandle.VirtualIndex.System_Runtime_WindowsRuntime] = "System.Runtime.WindowsRuntime";
                values[(int)StringHandle.VirtualIndex.System_Runtime]     = "System.Runtime";
                values[(int)StringHandle.VirtualIndex.System_ObjectModel] = "System.ObjectModel";
                values[(int)StringHandle.VirtualIndex.System_Runtime_WindowsRuntime_UI_Xaml]         = "System.Runtime.WindowsRuntime.UI.Xaml";
                values[(int)StringHandle.VirtualIndex.System_Runtime_InteropServices_WindowsRuntime] = "System.Runtime.InteropServices.WindowsRuntime";
                values[(int)StringHandle.VirtualIndex.System_Numerics_Vectors] = "System.Numerics.Vectors";

                values[(int)StringHandle.VirtualIndex.Dispose] = "Dispose";

                values[(int)StringHandle.VirtualIndex.AttributeTargets]        = "AttributeTargets";
                values[(int)StringHandle.VirtualIndex.AttributeUsageAttribute] = "AttributeUsageAttribute";
                values[(int)StringHandle.VirtualIndex.Color]                               = "Color";
                values[(int)StringHandle.VirtualIndex.CornerRadius]                        = "CornerRadius";
                values[(int)StringHandle.VirtualIndex.DateTimeOffset]                      = "DateTimeOffset";
                values[(int)StringHandle.VirtualIndex.Duration]                            = "Duration";
                values[(int)StringHandle.VirtualIndex.DurationType]                        = "DurationType";
                values[(int)StringHandle.VirtualIndex.EventHandler1]                       = "EventHandler`1";
                values[(int)StringHandle.VirtualIndex.EventRegistrationToken]              = "EventRegistrationToken";
                values[(int)StringHandle.VirtualIndex.Exception]                           = "Exception";
                values[(int)StringHandle.VirtualIndex.GeneratorPosition]                   = "GeneratorPosition";
                values[(int)StringHandle.VirtualIndex.GridLength]                          = "GridLength";
                values[(int)StringHandle.VirtualIndex.GridUnitType]                        = "GridUnitType";
                values[(int)StringHandle.VirtualIndex.ICommand]                            = "ICommand";
                values[(int)StringHandle.VirtualIndex.IDictionary2]                        = "IDictionary`2";
                values[(int)StringHandle.VirtualIndex.IDisposable]                         = "IDisposable";
                values[(int)StringHandle.VirtualIndex.IEnumerable]                         = "IEnumerable";
                values[(int)StringHandle.VirtualIndex.IEnumerable1]                        = "IEnumerable`1";
                values[(int)StringHandle.VirtualIndex.IList]                               = "IList";
                values[(int)StringHandle.VirtualIndex.IList1]                              = "IList`1";
                values[(int)StringHandle.VirtualIndex.INotifyCollectionChanged]            = "INotifyCollectionChanged";
                values[(int)StringHandle.VirtualIndex.INotifyPropertyChanged]              = "INotifyPropertyChanged";
                values[(int)StringHandle.VirtualIndex.IReadOnlyDictionary2]                = "IReadOnlyDictionary`2";
                values[(int)StringHandle.VirtualIndex.IReadOnlyList1]                      = "IReadOnlyList`1";
                values[(int)StringHandle.VirtualIndex.KeyTime]                             = "KeyTime";
                values[(int)StringHandle.VirtualIndex.KeyValuePair2]                       = "KeyValuePair`2";
                values[(int)StringHandle.VirtualIndex.Matrix]                              = "Matrix";
                values[(int)StringHandle.VirtualIndex.Matrix3D]                            = "Matrix3D";
                values[(int)StringHandle.VirtualIndex.Matrix3x2]                           = "Matrix3x2";
                values[(int)StringHandle.VirtualIndex.Matrix4x4]                           = "Matrix4x4";
                values[(int)StringHandle.VirtualIndex.NotifyCollectionChangedAction]       = "NotifyCollectionChangedAction";
                values[(int)StringHandle.VirtualIndex.NotifyCollectionChangedEventArgs]    = "NotifyCollectionChangedEventArgs";
                values[(int)StringHandle.VirtualIndex.NotifyCollectionChangedEventHandler] = "NotifyCollectionChangedEventHandler";
                values[(int)StringHandle.VirtualIndex.Nullable1]                           = "Nullable`1";
                values[(int)StringHandle.VirtualIndex.Plane]                               = "Plane";
                values[(int)StringHandle.VirtualIndex.Point]                               = "Point";
                values[(int)StringHandle.VirtualIndex.PropertyChangedEventArgs]            = "PropertyChangedEventArgs";
                values[(int)StringHandle.VirtualIndex.PropertyChangedEventHandler]         = "PropertyChangedEventHandler";
                values[(int)StringHandle.VirtualIndex.Quaternion]                          = "Quaternion";
                values[(int)StringHandle.VirtualIndex.Rect]                           = "Rect";
                values[(int)StringHandle.VirtualIndex.RepeatBehavior]                 = "RepeatBehavior";
                values[(int)StringHandle.VirtualIndex.RepeatBehaviorType]             = "RepeatBehaviorType";
                values[(int)StringHandle.VirtualIndex.Size]                           = "Size";
                values[(int)StringHandle.VirtualIndex.System]                         = "System";
                values[(int)StringHandle.VirtualIndex.System_Collections]             = "System.Collections";
                values[(int)StringHandle.VirtualIndex.System_Collections_Generic]     = "System.Collections.Generic";
                values[(int)StringHandle.VirtualIndex.System_Collections_Specialized] = "System.Collections.Specialized";
                values[(int)StringHandle.VirtualIndex.System_ComponentModel]          = "System.ComponentModel";
                values[(int)StringHandle.VirtualIndex.System_Numerics]                = "System.Numerics";
                values[(int)StringHandle.VirtualIndex.System_Windows_Input]           = "System.Windows.Input";
                values[(int)StringHandle.VirtualIndex.Thickness]                      = "Thickness";
                values[(int)StringHandle.VirtualIndex.TimeSpan]                       = "TimeSpan";
                values[(int)StringHandle.VirtualIndex.Type]                           = "Type";
                values[(int)StringHandle.VirtualIndex.Uri]                = "Uri";
                values[(int)StringHandle.VirtualIndex.Vector2]            = "Vector2";
                values[(int)StringHandle.VirtualIndex.Vector3]            = "Vector3";
                values[(int)StringHandle.VirtualIndex.Vector4]            = "Vector4";
                values[(int)StringHandle.VirtualIndex.Windows_Foundation] = "Windows.Foundation";
                values[(int)StringHandle.VirtualIndex.Windows_UI]         = "Windows.UI";
                values[(int)StringHandle.VirtualIndex.Windows_UI_Xaml]    = "Windows.UI.Xaml";
                values[(int)StringHandle.VirtualIndex.Windows_UI_Xaml_Controls_Primitives] = "Windows.UI.Xaml.Controls.Primitives";
                values[(int)StringHandle.VirtualIndex.Windows_UI_Xaml_Media]           = "Windows.UI.Xaml.Media";
                values[(int)StringHandle.VirtualIndex.Windows_UI_Xaml_Media_Animation] = "Windows.UI.Xaml.Media.Animation";
                values[(int)StringHandle.VirtualIndex.Windows_UI_Xaml_Media_Media3D]   = "Windows.UI.Xaml.Media.Media3D";

                s_virtualValues = values;
                AssertFilled();
            }

            this.Block = TrimEnd(block);
        }
Beispiel #23
0
        private static HashSet <string> ResolvePropertyNames(MetadataKind metadata)
        {
            var propertyNames = metadata.ToString().Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries);

            return(propertyNames.Length > 0 ? new HashSet <string>(MainProperties.Intersect(propertyNames)) : MainProperties);
        }
 protected static TestCaseData Case(TBuilder config, MetadataKind properties)
 {
     return(new TestCaseData((Func <string>)(() => SerializeAndDump(config, properties))));
 }
 public static void Dump(this IMetadataElement element, MetadataKind metadata, Type[] ignoredFeatures = null)
 {
     Debug.WriteLine(element.ToJson(true, ResolvePropertyNames(metadata), ignoredFeatures));
 }
Beispiel #26
0
        /// <summary>
        /// Looks like this function reads beginning of the header described in
        /// Ecma-335 24.2.1 Metadata root
        /// </summary>
        private void ReadMetadataHeader(ref BlobReader memReader)
        {
            if (memReader.RemainingBytes < COR20Constants.MinimumSizeofMetadataHeader)
            {
                throw new BadImageFormatException(MetadataResources.MetadataHeaderTooSmall);
            }

            this.metadataHeader.Signature = memReader.ReadUInt32();
            if (this.metadataHeader.Signature != COR20Constants.COR20MetadataSignature)
            {
                throw new BadImageFormatException(MetadataResources.MetadataSignature);
            }

            this.metadataHeader.MajorVersion = memReader.ReadUInt16();
            this.metadataHeader.MinorVersion = memReader.ReadUInt16();
            this.metadataHeader.ExtraData = memReader.ReadUInt32();
            this.metadataHeader.VersionStringSize = memReader.ReadInt32();
            if (memReader.RemainingBytes < this.metadataHeader.VersionStringSize)
            {
                throw new BadImageFormatException(MetadataResources.NotEnoughSpaceForVersionString);
            }

            int numberOfBytesRead;
            this.metadataHeader.VersionString = memReader.GetMemoryBlockAt(0, this.metadataHeader.VersionStringSize).PeekUtf8NullTerminated(0, null, utf8Decoder, out numberOfBytesRead, '\0');
            memReader.SkipBytes(this.metadataHeader.VersionStringSize);
            this.metadataKind = GetMetadataKind(metadataHeader.VersionString);
        }
 public static string Serialize(this IMetadataElement element, MetadataKind metadata, Type[] ignoredFeatures = null)
 {
     return element.ToJson(false, ResolvePropertyNames(metadata), ignoredFeatures).Replace("\"", "'");
 }