Loads the generator control manifest document. This document yields the Visual Studio project metadata (for new project files that we create) and the set of service configurations available to process.
コード例 #1
0
        /// <summary>
        /// Processes the control manifest to yield the set of services available to
        /// generate and the Visual Studio project file information used to create
        /// new projects for services.
        /// </summary>
        /// <param name="manifestPath">Path to the manifest file to pull basic info from</param>
        /// <param name="versionsPath">Path to _sdk-versions.json file</param>
        /// <param name="modelsFolder">Path to the service models to be parsed</param>
        public static GenerationManifest Load(string manifestPath, string versionsPath, string modelsFolder)
        {
            var generationManifest =
                new GenerationManifest(
                    new DefaultConfigurationController(
                        new FileReader(),
                        new DefaultConfigurationParser()));

            var manifest         = LoadJsonFromFile(manifestPath);
            var versionsManifest = LoadJsonFromFile(versionsPath);

            generationManifest.CoreFileVersion = versionsManifest["CoreVersion"].ToString();
            generationManifest.CoreVersion     = Utils.GetVersion(versionsManifest["OverrideCoreVersion"]?.ToString() ?? generationManifest.CoreFileVersion);

            generationManifest.DefaultToPreview = (bool)versionsManifest["DefaultToPreview"];
            if (generationManifest.DefaultToPreview)
            {
                generationManifest.PreviewLabel = (string)versionsManifest["PreviewLabel"];
            }
            if (!string.IsNullOrEmpty(generationManifest.PreviewLabel))
            {
                generationManifest.PreviewLabel = "-" + generationManifest.PreviewLabel;
            }

            generationManifest.LoadDefaultConfiguration(modelsFolder);
            generationManifest.LoadServiceConfigurations(manifest, versionsManifest["ServiceVersions"], modelsFolder);
            generationManifest.LoadProjectConfigurations(manifest);
            generationManifest.LoadUnitTestProjectConfigurations(manifest);

            return(generationManifest);
        }
コード例 #2
0
        /// <summary>
        /// Processes the control manifest to yield the set of services available to
        /// generate and the Visual Studio project file information used to create
        /// new projects for services.
        /// </summary>
        /// <param name="manifestPath">Path to the manifest file to pull basic info from</param>
        /// <param name="modelsFolder">Path to the service models to be parsed</param>
        public static GenerationManifest Load(string manifestPath, string versionsPath, string modelsFolder)
        {
            var generationManifest = new GenerationManifest();

            var manifest         = LoadJsonFromFile(manifestPath);
            var versionsManifest = LoadJsonFromFile(versionsPath);
            var coreVersionJson  = versionsManifest["CoreVersion"];

            generationManifest.CoreFileVersion = coreVersionJson.ToString();
            var versions = versionsManifest["ServiceVersions"];

            generationManifest.DefaultToPreview = (bool)versionsManifest["DefaultToPreview"];
            if (generationManifest.DefaultToPreview)
            {
                generationManifest.PreviewLabel = (string)versionsManifest["PreviewLabel"];
            }
            if (!string.IsNullOrEmpty(generationManifest.PreviewLabel))
            {
                generationManifest.PreviewLabel = "-" + generationManifest.PreviewLabel;
            }

            generationManifest.LoadServiceConfigurations(manifest, generationManifest.CoreFileVersion, versions, modelsFolder);
            generationManifest.LoadProjectConfigurations(manifest);

            return(generationManifest);
        }
コード例 #3
0
        public CoreAssemblyInfoUpdater(GeneratorOptions options, GenerationManifest manifest)
        {
            Manifest = manifest;
            Options = options;

            session = new Dictionary<string, object>
            {
                { "Version", Manifest.CoreVersion },
                { "FileVersion", Manifest.CoreFileVersion }
            };
        }
コード例 #4
0
ファイル: CoreUpdater.cs プロジェクト: rajdotnet/aws-sdk-net
        public CoreAssemblyInfoUpdater(GeneratorOptions options, GenerationManifest manifest)
        {
            Manifest = manifest;
            Options = options;

            session = new Dictionary<string, object>
            {
                { "Version", Manifest.CoreVersion },
                { "FileVersion", Manifest.CoreFileVersion }
            };

            session["NuGetPreviewFlag"] = manifest.DefaultToPreview ? GeneratorDriver.NuGetPreviewFlag : "";
        }
コード例 #5
0
ファイル: CoreUpdater.cs プロジェクト: yeurch/aws-sdk-net
        public CoreAssemblyInfoUpdater(GeneratorOptions options, GenerationManifest manifest)
        {
            Manifest = manifest;
            Options  = options;

            session = new Dictionary <string, object>
            {
                { "Version", Manifest.CoreVersion },
                { "FileVersion", Manifest.CoreFileVersion }
            };

            session["NuGetPreviewFlag"] = manifest.DefaultToPreview ? GeneratorDriver.NuGetPreviewFlag : "";
        }
コード例 #6
0
        public CoreAssemblyInfoUpdater(GeneratorOptions options, GenerationManifest manifest)
        {
            Manifest = manifest;
            Options  = options;

            session = new Dictionary <string, object>
            {
                { "Version", Manifest.CoreVersion },
                { "FileVersion", Manifest.CoreFileVersion }
            };

            session["NuGetPreviewFlag"]  = manifest.DefaultToPreview ? manifest.PreviewLabel : "";
            session["DisablePCLSupport"] = options.DisablePCLSupport;
        }
コード例 #7
0
ファイル: CoreUpdater.cs プロジェクト: aws/aws-sdk-net
        public CoreAssemblyInfoUpdater(GeneratorOptions options, GenerationManifest manifest)
        {
            Manifest = manifest;
            Options = options;

            session = new Dictionary<string, object>
            {
                { "Version", Manifest.CoreVersion },
                { "FileVersion", Manifest.CoreFileVersion }
            };

            session["NuGetPreviewFlag"] = manifest.DefaultToPreview ? manifest.PreviewLabel : "";
            session["DisablePCLSupport"] = options.DisablePCLSupport;
        }
コード例 #8
0
        /// <summary>
        /// Processes the control manifest to yield the set of services available to
        /// generate and the Visual Studio project file information used to create
        /// new projects for services.
        /// </summary>
        /// <param name="manifestPath">Path to the manifest file to pull basic info from</param>
        /// <param name="modelsFolder">Path to the service models to be parsed</param>
        public static GenerationManifest Load(string manifestPath, string versionsPath, string modelsFolder)
        {
            var generationManifest = new GenerationManifest();

            var manifest = LoadJsonFromFile(manifestPath);
            var versionsManifest = LoadJsonFromFile(versionsPath);
            var coreVersionJson = versionsManifest["CoreVersion"];
            generationManifest.CoreFileVersion = coreVersionJson.ToString();
            var versions = versionsManifest["ServiceVersions"];

            generationManifest.LoadServiceConfigurations(manifest, generationManifest.CoreFileVersion, versions, modelsFolder);
            generationManifest.LoadProjectConfigurations(manifest);

            return generationManifest;
        }
コード例 #9
0
        public GeneratorDriver(ServiceConfiguration config, GenerationManifest generationManifest, GeneratorOptions options)
        {
            GenerationManifest = generationManifest;
            Configuration = config;
            ProjectFileConfigurations = GenerationManifest.ProjectFileConfigurations;
            Options = options;

            // Base name in the manifest is not a reliable source of info, as if append-service
            // is set 'Service' gets appended and in the case of IAM then sends us to the wrong folder.
            // Instead we'll use the namespace and rip off any Amazon. prefix. This also helps us
            // handle versioned namespaces too.
            var serviceNameRoot = Configuration.Namespace.StartsWith("Amazon.", StringComparison.Ordinal) 
                ? Configuration.Namespace.Substring(7) 
                : Configuration.Namespace;

            ServiceFilesRoot = Path.Combine(Options.SdkRootFolder, SourceSubFoldername, ServicesSubFoldername, serviceNameRoot);
            GeneratedFilesRoot = Path.Combine(ServiceFilesRoot, GeneratedCodeFoldername);

            TestFilesRoot = Path.Combine(Options.SdkRootFolder, TestsSubFoldername);
        }
コード例 #10
0
        static int Main(string[] args)
        {
            var commandArguments = CommandArguments.Parse(args);

            if (!string.IsNullOrEmpty(commandArguments.Error))
            {
                Console.WriteLine(commandArguments.Error);
                return(-1);
            }

            var returnCode      = 0;
            var options         = commandArguments.ParsedOptions;
            var modelsToProcess = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            if (!string.IsNullOrEmpty(options.ServiceModels))
            {
                foreach (var s in options.ServiceModels.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    modelsToProcess.Add(s);
                }
            }

            try
            {
                if (options.CompileCustomizations) // Compile all servicename.customizations*.json files into one json file in bin
                {
                    CustomizationCompiler.CompileServiceCustomizations(options.ModelsFolder);
                }

                var generationManifest = GenerationManifest.Load(options.Manifest, options.Versions, options.ModelsFolder);

                if (string.IsNullOrEmpty(options.SelfServiceModel))
                {
                    HashSet <string> generatedFiles = new HashSet <string>();
                    GeneratorDriver.GenerateCoreProjects(generationManifest, options);
                    foreach (var serviceConfig in generationManifest.ServiceConfigurations)
                    {
                        if (modelsToProcess.Any() && !modelsToProcess.Contains(serviceConfig.ModelName))
                        {
                            Console.WriteLine("Skipping model (not in -servicemodels set to process): {0} ({1})", serviceConfig.ModelName, serviceConfig.ModelPath);
                            continue;
                        }

                        Console.WriteLine("Processing model: {0} ({1})", serviceConfig.ModelName, serviceConfig.ModelPath);
                        var driver = new GeneratorDriver(serviceConfig, generationManifest, options);
                        driver.Execute();
                        foreach (var file in driver.FilesWrittenToGeneratorFolder)
                        {
                            generatedFiles.Add(file);
                        }
                    }

                    GeneratorDriver.RemoveOrphanedShapes(generatedFiles, Path.Combine(options.SdkRootFolder, @"src\Services"));

                    GeneratorDriver.UpdateUnitTestProjects(generationManifest, options);
                    GeneratorDriver.UpdateSolutionFiles(generationManifest, options);
                    GeneratorDriver.UpdateAssemblyVersionInfo(generationManifest, options);
                    GeneratorDriver.UpdateNuGetPackagesInReadme(generationManifest, options);
                    GeneratorDriver.UpdateCoreCLRTestDependencies(generationManifest, options);
                    GeneratorDriver.UpdateCodeAnalysisSoltion(generationManifest, options);
                }
                else
                {
                    var serviceConfig = new ServiceConfiguration
                    {
                        ModelPath          = options.SelfServiceModel,
                        ServiceFileVersion = "3.1.0.0"
                    };
                    serviceConfig.ModelName           = Path.GetFileName(serviceConfig.ModelPath);
                    serviceConfig.ServiceDependencies = new Dictionary <string, string> {
                        { "Core", "3.1.0.0" }
                    };
                    serviceConfig.GenerateConstructors = true;


                    var relativePathToCustomizations = Path.Combine("customizations", string.Format("{0}.customizations.json", options.SelfServiceBaseName.ToLowerInvariant()));
                    if (File.Exists(relativePathToCustomizations))
                    {
                        serviceConfig.CustomizationsPath = Path.GetFullPath(relativePathToCustomizations);
                        Console.WriteLine("Using customization file: {0}", serviceConfig.CustomizationsPath);
                    }

                    Console.WriteLine("Processing self service {0} with model {1}.", options.SelfServiceBaseName, options.SelfServiceModel);
                    var driver = new GeneratorDriver(serviceConfig, generationManifest, options);
                    driver.Execute();

                    // Skip orphan clean for DynamoDB because of the complex nature of DynamDB and DynamoDB Streams
                    if (!serviceConfig.ClassName.StartsWith("DynamoDB"))
                    {
                        GeneratorDriver.RemoveOrphanedShapes(driver.FilesWrittenToGeneratorFolder, driver.GeneratedFilesRoot);
                    }
                }
            }
            catch (Exception e)
            {
                if (options.WaitOnExit)
                {
                    Console.Error.WriteLine("Error running generator: " + e.Message);
                    Console.Error.WriteLine(e.StackTrace);
                    returnCode = -1;
                }
                else
                {
                    throw;
                }
            }

            if (options.WaitOnExit)
            {
                Console.WriteLine();
                Console.WriteLine("Generation complete. Press a key to exit.");
                Console.ReadLine();
            }

            return(returnCode);
        }
コード例 #11
0
        public static void UpdateNuGetPackagesInReadme(GenerationManifest manifest, GeneratorOptions options)
        {
            var nugetPackages = new Dictionary<string, string>();
            foreach(var service in manifest.ServiceConfigurations.OrderBy(x => x.BaseName))
            {
                // Service like DynamoDB streams are included in a parent service.
                if (service.ParentConfig != null)
                    continue;

                if(string.IsNullOrEmpty(service.Synopsis))
                    throw new Exception(string.Format("{0} is missing a synopsis in the manifest.", service.BaseName));
                var assemblyName = service.Namespace.Replace("Amazon.", "AWSSDK.");
                nugetPackages[assemblyName] = service.Synopsis;
            }

            NuGetPackageReadmeSection generator = new NuGetPackageReadmeSection();
            var session = new Dictionary<string, object> { { "NugetPackages", nugetPackages } };
            generator.Session = session;
            var nugetPackagesText = generator.TransformText();

            var readmePath = Path.Combine(options.SdkRootFolder, "..", "README.md");
            var originalContent = File.ReadAllText(readmePath);

            int startPos = originalContent.IndexOf('\n', originalContent.IndexOf("### NuGet Packages")) + 1;
            int endPos = originalContent.IndexOf("### Code Generator");

            var newContent = originalContent.Substring(0, startPos);
            newContent += nugetPackagesText + "\r\n";
            newContent += originalContent.Substring(endPos);

            File.WriteAllText(readmePath, newContent);
        }
コード例 #12
0
 public static void UpdateAssemblyVersionInfo(GenerationManifest manifest, GeneratorOptions options)
 {
     var updater = new CoreAssemblyInfoUpdater(options, manifest);
     updater.Execute();
 }
コード例 #13
0
 public static void UpdateCodeAnalysisSoltion(GenerationManifest manifest, GeneratorOptions options)
 {
     Console.WriteLine("Updating code analysis solution file.");
     var creator = new CodeAnalysisSolutionCreator
     {
         Options = options
     };
     creator.Execute();
 }
コード例 #14
0
 public static void UpdateSolutionFiles(GenerationManifest manifest, GeneratorOptions options)
 {
     Console.WriteLine("Updating solution files.");
     var solutionFileCreator = new SolutionFileCreator
     {
         Options = options,
         ProjectFileConfigurations = manifest.ProjectFileConfigurations
     };
     solutionFileCreator.Execute(NewlyCreatedProjectFiles);
 }
コード例 #15
0
 public static void GenerateCoreProjects(GenerationManifest generationManifest,
     GeneratorOptions options)
 {
     Console.WriteLine("Updating Core project files.");
     string coreFilesRoot = Path.Combine(options.SdkRootFolder, "src", "core");
     var creator = new ProjectFileCreator();
     creator.ExecuteCore(coreFilesRoot, generationManifest.ProjectFileConfigurations);
     foreach (var newProjectKey in creator.CreatedProjectFiles.Keys)
     {
         NewlyCreatedProjectFiles.Add(newProjectKey, creator.CreatedProjectFiles[newProjectKey]);
     }
 }
コード例 #16
0
ファイル: GenerationManifest.cs プロジェクト: aws/aws-sdk-net
        /// <summary>
        /// Processes the control manifest to yield the set of services available to
        /// generate and the Visual Studio project file information used to create
        /// new projects for services.
        /// </summary>
        /// <param name="manifestPath">Path to the manifest file to pull basic info from</param>
        /// <param name="modelsFolder">Path to the service models to be parsed</param>
        public static GenerationManifest Load(string manifestPath, string versionsPath, string modelsFolder)
        {
            var generationManifest = new GenerationManifest();

            var manifest = LoadJsonFromFile(manifestPath);
            var versionsManifest = LoadJsonFromFile(versionsPath);
            var coreVersionJson = versionsManifest["CoreVersion"];
            generationManifest.CoreFileVersion = coreVersionJson.ToString();
            var versions = versionsManifest["ServiceVersions"];

            generationManifest.DefaultToPreview = (bool)versionsManifest["DefaultToPreview"];
			if (generationManifest.DefaultToPreview)
			{
				generationManifest.PreviewLabel = (string)versionsManifest["PreviewLabel"];
			}
            if (!string.IsNullOrEmpty(generationManifest.PreviewLabel))
                generationManifest.PreviewLabel = "-" + generationManifest.PreviewLabel;

            generationManifest.LoadServiceConfigurations(manifest, generationManifest.CoreFileVersion, versions, modelsFolder);
            generationManifest.LoadProjectConfigurations(manifest);

            return generationManifest;
        }
コード例 #17
0
ファイル: GeneratorDriver.cs プロジェクト: aws/aws-sdk-net
        public static void UpdateCoreCLRTestDependencies(GenerationManifest manifest, GeneratorOptions options)
        {
            var projectJsonPath = Path.Combine(options.SdkRootFolder, "test/CoreCLR/IntegrationTests/project.json");
            var originalProjectJson = File.ReadAllText(projectJsonPath);

            var rootData = JsonMapper.ToObject(originalProjectJson);
            var dependency = rootData["dependencies"] as JsonData;

            bool hasChanged = false;

            foreach (var service in manifest.ServiceConfigurations.OrderBy(x => x.ServiceFolderName))
            {
                if (service.ParentConfig != null)
                    continue;

                if(service.CoreCLRSupport && dependency[service.ServiceFolderName] == null)
                {
                    hasChanged = true;
                    dependency[service.ServiceFolderName] = "1.0.0-*";
                }
            }



            if(hasChanged)
            {
                var newContent = new System.Text.StringBuilder();
                JsonWriter writer = new JsonWriter(newContent) { PrettyPrint = true };
                rootData.ToJson(writer);
                File.WriteAllText(projectJsonPath, newContent.ToString().Trim());
            }
        }