private void ReadRuntimeTarget(JsonTextReader reader, out string runtimeTargetName, out string runtimeSignature)
        {
            runtimeTargetName = null;
            runtimeSignature  = null;

            reader.ReadStartObject();

            string propertyName;
            string propertyValue;

            while (reader.TryReadStringProperty(out propertyName, out propertyValue))
            {
                switch (propertyName)
                {
                case DependencyContextStrings.RuntimeTargetNamePropertyName:
                    runtimeTargetName = propertyValue;
                    break;

                case DependencyContextStrings.RuntimeTargetSignaturePropertyName:
                    runtimeSignature = propertyValue;
                    break;

                default:
                    throw new FormatException($"Unknown property name '{propertyName}'");
                }
            }

            reader.CheckEndObject();
        }
Esempio n. 2
0
        private void ReadRuntimeTarget(JsonTextReader reader, out string runtimeTargetName, out string runtimeSignature)
        {
            runtimeTargetName = null;
            runtimeSignature  = null;

            reader.ReadStartObject();

            string propertyName;
            string propertyValue;

            while (reader.TryReadStringProperty(out propertyName, out propertyValue))
            {
                switch (propertyName)
                {
                case DependencyContextStrings.RuntimeTargetNamePropertyName:
                    runtimeTargetName = propertyValue;
                    break;

                case DependencyContextStrings.RuntimeTargetSignaturePropertyName:
                    runtimeSignature = propertyValue;
                    break;
                }
            }

            reader.CheckEndObject();
        }
        private List <RuntimeTargetEntryStub> ReadTargetLibraryRuntimeTargets(JsonTextReader reader)
        {
            var runtimeTargets = new List <RuntimeTargetEntryStub>();

            reader.ReadStartObject();

            while (reader.Read() && reader.TokenType == JsonToken.PropertyName)
            {
                var runtimeTarget = new RuntimeTargetEntryStub();
                runtimeTarget.Path = (string)reader.Value;

                reader.ReadStartObject();

                string propertyName;
                string propertyValue;
                while (reader.TryReadStringProperty(out propertyName, out propertyValue))
                {
                    switch (propertyName)
                    {
                    case DependencyContextStrings.RidPropertyName:
                        runtimeTarget.Rid = Pool(propertyValue);
                        break;

                    case DependencyContextStrings.AssetTypePropertyName:
                        runtimeTarget.Type = Pool(propertyValue);
                        break;

                    case DependencyContextStrings.AssemblyVersionPropertyName:
                        runtimeTarget.AssemblyVersion = propertyValue;
                        break;

                    case DependencyContextStrings.FileVersionPropertyName:
                        runtimeTarget.FileVersion = propertyValue;
                        break;
                    }
                }

                reader.CheckEndObject();

                runtimeTargets.Add(runtimeTarget);
            }

            reader.CheckEndObject();

            return(runtimeTargets);
        }
        private LibraryStub ReadOneLibrary(JsonTextReader reader)
        {
            string hash        = null;
            string type        = null;
            bool   serviceable = false;
            string path        = null;
            string hashPath    = null;
            string runtimeStoreManifestName = null;

            reader.ReadStartObject();

            while (reader.Read() && reader.TokenType == JsonToken.PropertyName)
            {
                switch ((string)reader.Value)
                {
                case DependencyContextStrings.Sha512PropertyName:
                    hash = reader.ReadAsString();
                    break;

                case DependencyContextStrings.TypePropertyName:
                    type = reader.ReadAsString();
                    break;

                case DependencyContextStrings.ServiceablePropertyName:
                    serviceable = reader.ReadAsBoolean().GetValueOrDefault(false);
                    break;

                case DependencyContextStrings.PathPropertyName:
                    path = reader.ReadAsString();
                    break;

                case DependencyContextStrings.HashPathPropertyName:
                    hashPath = reader.ReadAsString();
                    break;

                case DependencyContextStrings.RuntimeStoreManifestPropertyName:
                    runtimeStoreManifestName = reader.ReadAsString();
                    break;

                default:
                    reader.Skip();
                    break;
                }
            }

            reader.CheckEndObject();

            return(new LibraryStub()
            {
                Hash = hash,
                Type = Pool(type),
                Serviceable = serviceable,
                Path = path,
                HashPath = hashPath,
                RuntimeStoreManifestName = runtimeStoreManifestName
            });
        }
        private List <RuntimeTargetEntryStub> ReadTargetLibraryRuntimeTargets(JsonTextReader reader)
        {
            var runtimeTargets = new List <RuntimeTargetEntryStub>();

            reader.ReadStartObject();

            while (reader.Read() && reader.TokenType == JsonToken.PropertyName)
            {
                var runtimeTarget = new RuntimeTargetEntryStub();
                runtimeTarget.Path = (string)reader.Value;

                reader.ReadStartObject();

                string propertyName;
                string propertyValue;
                while (reader.TryReadStringProperty(out propertyName, out propertyValue))
                {
                    switch (propertyName)
                    {
                    case DependencyContextStrings.RidPropertyName:
                        runtimeTarget.Rid = Pool(propertyValue);
                        break;

                    case DependencyContextStrings.AssetTypePropertyName:
                        runtimeTarget.Type = Pool(propertyValue);
                        break;

                    default:
                        throw new FormatException($"Unknown property name '{propertyName}'");
                    }
                }

                reader.CheckEndObject();

                runtimeTargets.Add(runtimeTarget);
            }

            reader.CheckEndObject();

            return(runtimeTargets);
        }
        private List <RuntimeFile> ReadRuntimeFiles(JsonTextReader reader)
        {
            var runtimeFiles = new List <RuntimeFile>();

            reader.ReadStartObject();

            while (reader.Read() && reader.TokenType == JsonToken.PropertyName)
            {
                string assemblyVersion = null;
                string fileVersion     = null;

                var path = (string)reader.Value;

                reader.ReadStartObject();

                string propertyName;
                string propertyValue;
                while (reader.TryReadStringProperty(out propertyName, out propertyValue))
                {
                    switch (propertyName)
                    {
                    case DependencyContextStrings.AssemblyVersionPropertyName:
                        assemblyVersion = propertyValue;
                        break;

                    case DependencyContextStrings.FileVersionPropertyName:
                        fileVersion = propertyValue;
                        break;
                    }
                }

                reader.CheckEndObject();

                runtimeFiles.Add(new RuntimeFile(path, assemblyVersion, fileVersion));
            }

            reader.CheckEndObject();

            return(runtimeFiles);
        }
Esempio n. 7
0
        private List <ResourceAssembly> ReadTargetLibraryResources(JsonTextReader reader)
        {
            var resources = new List <ResourceAssembly>();

            reader.ReadStartObject();

            while (reader.Read() && reader.TokenType == JsonToken.PropertyName)
            {
                var    path   = (string)reader.Value;
                string locale = null;

                reader.ReadStartObject();

                string propertyName;
                string propertyValue;

                while (reader.TryReadStringProperty(out propertyName, out propertyValue))
                {
                    if (propertyName == DependencyContextStrings.LocalePropertyName)
                    {
                        locale = propertyValue;
                    }
                }

                reader.CheckEndObject();

                if (locale != null)
                {
                    resources.Add(new ResourceAssembly(path, Pool(locale)));
                }
            }

            reader.CheckEndObject();

            return(resources);
        }
Esempio n. 8
0
        private List <Target> ReadTargets(JsonTextReader reader)
        {
            reader.ReadStartObject();

            var targets = new List <Target>();

            while (reader.Read() && reader.TokenType == JsonToken.PropertyName)
            {
                targets.Add(ReadTarget(reader, (string)reader.Value));
            }

            reader.CheckEndObject();

            return(targets);
        }
Esempio n. 9
0
        private Dictionary <string, LibraryStub> ReadLibraries(JsonTextReader reader)
        {
            var libraries = new Dictionary <string, LibraryStub>();

            reader.ReadStartObject();

            while (reader.Read() && reader.TokenType == JsonToken.PropertyName)
            {
                var libraryName = (string)reader.Value;

                libraries.Add(Pool(libraryName), ReadOneLibrary(reader));
            }

            reader.CheckEndObject();

            return(libraries);
        }
Esempio n. 10
0
        public IEnumerable <Dependency> ReadTargetLibraryDependencies(JsonTextReader reader)
        {
            var    dependencies = new List <Dependency>();
            string name;
            string version;

            reader.ReadStartObject();

            while (reader.TryReadStringProperty(out name, out version))
            {
                dependencies.Add(new Dependency(Pool(name), Pool(version)));
            }

            reader.CheckEndObject();

            return(dependencies);
        }
Esempio n. 11
0
        private List <RuntimeFallbacks> ReadRuntimes(JsonTextReader reader)
        {
            var runtimeFallbacks = new List <RuntimeFallbacks>();

            reader.ReadStartObject();

            while (reader.Read() && reader.TokenType == JsonToken.PropertyName)
            {
                var runtime   = (string)reader.Value;
                var fallbacks = reader.ReadStringArray();

                runtimeFallbacks.Add(new RuntimeFallbacks(runtime, fallbacks));
            }

            reader.CheckEndObject();

            return(runtimeFallbacks);
        }
Esempio n. 12
0
        private List <string> ReadPropertyNames(JsonTextReader reader)
        {
            var runtimes = new List <string>();

            reader.ReadStartObject();

            while (reader.Read() && reader.TokenType == JsonToken.PropertyName)
            {
                var libraryName = (string)reader.Value;
                reader.Skip();

                runtimes.Add(libraryName);
            }

            reader.CheckEndObject();

            return(runtimes);
        }
        private LibraryStub ReadOneLibrary(JsonTextReader reader)
        {
            string hash        = null;
            string type        = null;
            bool   serviceable = false;
            string path        = null;

            reader.ReadStartObject();

            while (reader.Read() && reader.TokenType == JsonToken.PropertyName)
            {
                switch ((string)reader.Value)
                {
                case DependencyContextStrings.Sha512PropertyName:
                    hash = reader.ReadAsString();
                    break;

                case DependencyContextStrings.TypePropertyName:
                    type = reader.ReadAsString();
                    break;

                case DependencyContextStrings.ServiceablePropertyName:
                    serviceable = reader.ReadAsBoolean().GetValueOrDefault(false);
                    break;

                case DependencyContextStrings.PathPropertyName:
                    path = reader.ReadAsString();
                    break;

                default:
                    throw new FormatException($"Unknown property name '{reader.Value}'");
                }
            }

            reader.CheckEndObject();

            return(new LibraryStub()
            {
                Hash = hash,
                Type = Pool(type),
                Serviceable = serviceable,
                Path = path
            });
        }
Esempio n. 14
0
        private Target ReadTarget(JsonTextReader reader, string targetName)
        {
            reader.ReadStartObject();

            var libraries = new List <TargetLibrary>();

            while (reader.Read() && reader.TokenType == JsonToken.PropertyName)
            {
                libraries.Add(ReadTargetLibrary(reader, (string)reader.Value));
            }

            reader.CheckEndObject();

            return(new Target()
            {
                Name = targetName,
                Libraries = libraries
            });
        }
Esempio n. 15
0
        private TargetLibrary ReadTargetLibrary(JsonTextReader reader, string targetLibraryName)
        {
            IEnumerable <Dependency>      dependencies   = null;
            List <string>                 runtimes       = null;
            List <string>                 natives        = null;
            List <string>                 compilations   = null;
            List <RuntimeTargetEntryStub> runtimeTargets = null;
            List <ResourceAssembly>       resources      = null;
            bool?compileOnly = null;

            reader.ReadStartObject();

            while (reader.Read() && reader.TokenType == JsonToken.PropertyName)
            {
                switch ((string)reader.Value)
                {
                case DependencyContextStrings.DependenciesPropertyName:
                    dependencies = ReadTargetLibraryDependencies(reader);
                    break;

                case DependencyContextStrings.RuntimeAssembliesKey:
                    runtimes = ReadPropertyNames(reader);
                    break;

                case DependencyContextStrings.NativeLibrariesKey:
                    natives = ReadPropertyNames(reader);
                    break;

                case DependencyContextStrings.CompileTimeAssembliesKey:
                    compilations = ReadPropertyNames(reader);
                    break;

                case DependencyContextStrings.RuntimeTargetsPropertyName:
                    runtimeTargets = ReadTargetLibraryRuntimeTargets(reader);
                    break;

                case DependencyContextStrings.ResourceAssembliesPropertyName:
                    resources = ReadTargetLibraryResources(reader);
                    break;

                case DependencyContextStrings.CompilationOnlyPropertyName:
                    compileOnly = reader.ReadAsBoolean();
                    break;

                default:
                    reader.Skip();
                    break;
                }
            }

            reader.CheckEndObject();

            return(new TargetLibrary()
            {
                Name = targetLibraryName,
                Dependencies = dependencies ?? Enumerable.Empty <Dependency>(),
                Runtimes = runtimes,
                Natives = natives,
                Compilations = compilations,
                RuntimeTargets = runtimeTargets,
                Resources = resources,
                CompileOnly = compileOnly
            });
        }
Esempio n. 16
0
        private CompilationOptions ReadCompilationOptions(JsonTextReader reader)
        {
            IEnumerable <string> defines = null;
            string languageVersion       = null;
            string platform                 = null;
            bool?  allowUnsafe              = null;
            bool?  warningsAsErrors         = null;
            bool?  optimize                 = null;
            string keyFile                  = null;
            bool?  delaySign                = null;
            bool?  publicSign               = null;
            string debugType                = null;
            bool?  emitEntryPoint           = null;
            bool?  generateXmlDocumentation = null;

            reader.ReadStartObject();

            while (reader.Read() && reader.TokenType == JsonToken.PropertyName)
            {
                switch ((string)reader.Value)
                {
                case DependencyContextStrings.DefinesPropertyName:
                    defines = reader.ReadStringArray();
                    break;

                case DependencyContextStrings.LanguageVersionPropertyName:
                    languageVersion = reader.ReadAsString();
                    break;

                case DependencyContextStrings.PlatformPropertyName:
                    platform = reader.ReadAsString();
                    break;

                case DependencyContextStrings.AllowUnsafePropertyName:
                    allowUnsafe = reader.ReadAsBoolean();
                    break;

                case DependencyContextStrings.WarningsAsErrorsPropertyName:
                    warningsAsErrors = reader.ReadAsBoolean();
                    break;

                case DependencyContextStrings.OptimizePropertyName:
                    optimize = reader.ReadAsBoolean();
                    break;

                case DependencyContextStrings.KeyFilePropertyName:
                    keyFile = reader.ReadAsString();
                    break;

                case DependencyContextStrings.DelaySignPropertyName:
                    delaySign = reader.ReadAsBoolean();
                    break;

                case DependencyContextStrings.PublicSignPropertyName:
                    publicSign = reader.ReadAsBoolean();
                    break;

                case DependencyContextStrings.DebugTypePropertyName:
                    debugType = reader.ReadAsString();
                    break;

                case DependencyContextStrings.EmitEntryPointPropertyName:
                    emitEntryPoint = reader.ReadAsBoolean();
                    break;

                case DependencyContextStrings.GenerateXmlDocumentationPropertyName:
                    generateXmlDocumentation = reader.ReadAsBoolean();
                    break;

                default:
                    reader.Skip();
                    break;
                }
            }

            reader.CheckEndObject();

            return(new CompilationOptions(
                       defines ?? Enumerable.Empty <string>(),
                       languageVersion,
                       platform,
                       allowUnsafe,
                       warningsAsErrors,
                       optimize,
                       keyFile,
                       delaySign,
                       publicSign,
                       debugType,
                       emitEntryPoint,
                       generateXmlDocumentation));
        }