private IEnumerable <Dependency> ReadTargetLibraryDependencies(ref Utf8JsonReader reader) { var dependencies = new List <Dependency>(); reader.ReadStartObject(); while (reader.TryReadStringProperty(out string?name, out string?version)) { if (string.IsNullOrEmpty(name)) { throw new FormatException(SR.Format(SR.RequiredFieldNotSpecified, nameof(name))); } if (string.IsNullOrEmpty(version)) { throw new FormatException(SR.Format(SR.RequiredFieldNotSpecified, nameof(version))); } dependencies.Add(new Dependency(Pool(name), Pool(version))); } reader.CheckEndObject(); return(dependencies); }
private TargetLibrary ReadTargetLibrary(ref Utf8JsonReader 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.GetString()) { 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 }); }
private static CompilationOptions ReadCompilationOptions(ref Utf8JsonReader 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.GetString()) { 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)); }
private LibraryStub ReadOneLibrary(ref Utf8JsonReader 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.GetString()) { 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(); if (string.IsNullOrEmpty(type)) { throw new FormatException(SR.Format(SR.RequiredFieldNotSpecified, nameof(type))); } return(new LibraryStub() { Hash = hash, Type = Pool(type), Serviceable = serviceable, Path = path, HashPath = hashPath, RuntimeStoreManifestName = runtimeStoreManifestName }); }