コード例 #1
0
        private List <ResourceAssembly> ReadTargetLibraryResources(ref UnifiedJsonReader reader)
        {
            var resources = new List <ResourceAssembly>();

            reader.ReadStartObject();

            while (reader.Read() && reader.IsTokenTypeProperty())
            {
                string path   = reader.GetStringValue();
                string locale = null;

                reader.ReadStartObject();

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

                reader.CheckEndObject();

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

            reader.CheckEndObject();

            return(resources);
        }
コード例 #2
0
        private List <RuntimeTargetEntryStub> ReadTargetLibraryRuntimeTargets(ref UnifiedJsonReader reader)
        {
            var runtimeTargets = new List <RuntimeTargetEntryStub>();

            reader.ReadStartObject();

            while (reader.Read() && reader.IsTokenTypeProperty())
            {
                var runtimeTarget = new RuntimeTargetEntryStub
                {
                    Path = reader.GetStringValue()
                };

                reader.ReadStartObject();

                while (reader.TryReadStringProperty(out string propertyName, out string 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);
        }
コード例 #3
0
        private LibraryStub ReadOneLibrary(ref UnifiedJsonReader 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.IsTokenTypeProperty())
            {
                switch (reader.GetStringValue())
                {
                case DependencyContextStrings.Sha512PropertyName:
                    hash = reader.ReadAsString();
                    break;

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

                case DependencyContextStrings.ServiceablePropertyName:
                    serviceable = reader.ReadAsBoolean(defaultValue: 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
            });
        }
コード例 #4
0
        private static List <RuntimeFile> ReadRuntimeFiles(ref UnifiedJsonReader reader)
        {
            var runtimeFiles = new List <RuntimeFile>();

            reader.ReadStartObject();

            while (reader.Read() && reader.IsTokenTypeProperty())
            {
                string assemblyVersion = null;
                string fileVersion     = null;

                string path = reader.GetStringValue();

                reader.ReadStartObject();

                while (reader.TryReadStringProperty(out string propertyName, out string 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);
        }
コード例 #5
0
        private IEnumerable <Dependency> ReadTargetLibraryDependencies(ref UnifiedJsonReader reader)
        {
            var dependencies = new List <Dependency>();

            reader.ReadStartObject();

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

            reader.CheckEndObject();

            return(dependencies);
        }
コード例 #6
0
        private List <Target> ReadTargets(ref UnifiedJsonReader reader)
        {
            reader.ReadStartObject();

            var targets = new List <Target>();

            while (reader.Read() && reader.IsTokenTypeProperty())
            {
                targets.Add(ReadTarget(ref reader, reader.GetStringValue()));
            }

            reader.CheckEndObject();

            return(targets);
        }
コード例 #7
0
        private Dictionary <string, LibraryStub> ReadLibraries(ref UnifiedJsonReader reader)
        {
            var libraries = new Dictionary <string, LibraryStub>();

            reader.ReadStartObject();

            while (reader.Read() && reader.IsTokenTypeProperty())
            {
                string libraryName = reader.GetStringValue();

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

            reader.CheckEndObject();

            return(libraries);
        }
コード例 #8
0
        private static List <RuntimeFallbacks> ReadRuntimes(ref UnifiedJsonReader reader)
        {
            var runtimeFallbacks = new List <RuntimeFallbacks>();

            reader.ReadStartObject();

            while (reader.Read() && reader.IsTokenTypeProperty())
            {
                string   runtime   = reader.GetStringValue();
                string[] fallbacks = reader.ReadStringArray();

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

            reader.CheckEndObject();

            return(runtimeFallbacks);
        }
コード例 #9
0
        private static List <string> ReadPropertyNames(ref UnifiedJsonReader reader)
        {
            var runtimes = new List <string>();

            reader.ReadStartObject();

            while (reader.Read() && reader.IsTokenTypeProperty())
            {
                string libraryName = reader.GetStringValue();
                reader.Skip();

                runtimes.Add(libraryName);
            }

            reader.CheckEndObject();

            return(runtimes);
        }
コード例 #10
0
        private Target ReadTarget(ref UnifiedJsonReader reader, string targetName)
        {
            reader.ReadStartObject();

            var libraries = new List <TargetLibrary>();

            while (reader.Read() && reader.IsTokenTypeProperty())
            {
                libraries.Add(ReadTargetLibrary(ref reader, reader.GetStringValue()));
            }

            reader.CheckEndObject();

            return(new Target()
            {
                Name = targetName,
                Libraries = libraries
            });
        }
コード例 #11
0
        private static void ReadRuntimeTarget(ref UnifiedJsonReader reader, out string runtimeTargetName, out string runtimeSignature)
        {
            runtimeTargetName = null;
            runtimeSignature  = null;

            reader.ReadStartObject();

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

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

            reader.CheckEndObject();
        }
コード例 #12
0
        private TargetLibrary ReadTargetLibrary(ref UnifiedJsonReader reader, string targetLibraryName)
        {
            IEnumerable <Dependency>      dependencies   = null;
            List <RuntimeFile>            runtimes       = null;
            List <RuntimeFile>            natives        = null;
            List <string>                 compilations   = null;
            List <RuntimeTargetEntryStub> runtimeTargets = null;
            List <ResourceAssembly>       resources      = null;
            bool?compileOnly = null;

            reader.ReadStartObject();

            while (reader.Read() && reader.IsTokenTypeProperty())
            {
                switch (reader.GetStringValue())
                {
                case DependencyContextStrings.DependenciesPropertyName:
                    dependencies = ReadTargetLibraryDependencies(ref reader);
                    break;

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

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

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

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

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

                case DependencyContextStrings.CompilationOnlyPropertyName:
                    compileOnly = reader.ReadAsNullableBoolean();
                    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
            });
        }
コード例 #13
0
        private static CompilationOptions ReadCompilationOptions(ref UnifiedJsonReader 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.IsTokenTypeProperty())
            {
                switch (reader.GetStringValue())
                {
                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.ReadAsNullableBoolean();
                    break;

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

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

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

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

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

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

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

                case DependencyContextStrings.GenerateXmlDocumentationPropertyName:
                    generateXmlDocumentation = reader.ReadAsNullableBoolean();
                    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));
        }