コード例 #1
0
        public override bool Execute()
        {
            ILogger logger        = new LoggerThatUsesTaskOutput(this);
            string  operationName = "C#/XAML for HTML5: AssemblyReferenceValidator";

            try
            {
                return(CheckingThatAssembliesCanBeReferenced.Check(References, AllowedAssemblies, ActivationAppPath, Flags, logger, IsBridgeBasedVersion, NameOfAssembliesThatDoNotContainUserCode, ProjectDir, ReferencesPaths, TypeForwardingAssemblyPath));
            }
            catch (CompilationExceptionWithOptions ex)
            {
                if (ex.DisplayOnlyTheMessageInTheOutputNothingElse)
                {
                    logger.WriteError(ex.Message);
                }
                else
                {
                    logger.WriteError(operationName + " failed: " + ex.ToString());
                }
                return(false);
            }
            catch (Exception ex)
            {
                logger.WriteError(operationName + " failed: " + ex.ToString());
                return(false);
            }

            //todo: verify also that the "ProjectReferences" (not just the "References") are of type C#/XAML for HTML5. In fact, in the current version, we do the test for the referenced DLLs, but not for the referenced projects (ie. when a project references another project).
        }
コード例 #2
0
        public override bool Execute()
        {
            ILogger logger        = new LoggerThatUsesTaskOutput(this);
            string  operationName = "C#/XAML for HTML5: EntryPointGenerator";

            try
            {
                // Validate input strings:
                if (string.IsNullOrEmpty(OutputFile))
                {
                    throw new Exception(operationName + " failed because the output file argument is invalid.");
                }

                //------- DISPLAY THE PROGRESS -------
                logger.WriteMessage(operationName + " started.");

                // Generate attributes:
                string generatedCode = string.Format(@"
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was auto-generated by ""C#/XAML for HTML5""
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace CSHTML5.Generated
{{
    static class CSHTML5_Entry_Point
    {{
        public static void Main()
        {{
            new App();
        }}
    }}
}}

");

                // Create output directory:
                Directory.CreateDirectory(Path.GetDirectoryName(OutputFile));

                // Save output:
                using (StreamWriter outfile = new StreamWriter(OutputFile))
                {
                    outfile.Write(generatedCode);
                }

                //------- DISPLAY THE PROGRESS -------
                logger.WriteMessage(operationName + " completed.");

                return(true);
            }
            catch (Exception ex)
            {
                logger.WriteError(operationName + " failed: " + ex.ToString());
                return(false);
            }
        }
コード例 #3
0
        public override bool Execute()
        {
            if (InputFiles == null)
            {
                return(true);
            }
            ILogger logger        = new LoggerThatUsesTaskOutput(this);
            string  operationName = "C#/XAML for HTML5: TypeScriptDefToCSharp";

            try
            {
                // Execute the task if needed
                if (NoRecompile == false)
                {
                    ProcessTypeScriptDef.ProcessTypeScriptDefFile(this.InputFiles, this.OutputDirectory, logger);
                }

                // Get the file list from the XML
                List <string> ListOfGeneratedFiles = new List <string>();
                if (File.Exists(OutputDirectory + global::TypeScriptDefToCSharp.Constants.NAME_OF_TYPESCRIPT_DEFINITIONS_CACHE_FILE))
                {
                    // Read the XML
                    string content = File.ReadAllText(OutputDirectory + global::TypeScriptDefToCSharp.Constants.NAME_OF_TYPESCRIPT_DEFINITIONS_CACHE_FILE);
                    // Deserialize
                    TypeScriptDefToCSharpOutput output = Tool.Deserialize <TypeScriptDefToCSharpOutput>(content);

                    // Store every generated file in our list
                    foreach (var file in output.TypeScriptDefinitionFiles)
                    {
                        ListOfGeneratedFiles.AddRange(file.CSharpGeneratedFiles);
                    }
                }
                // Convert them to get the output
                GeneratedFiles = ListOfGeneratedFiles.Select(s => new TaskItem()
                {
                    ItemSpec = s
                }).ToArray();

                logger.WriteMessage("Output directory: " + this.OutputDirectory, MessageImportance.High);
            }
            catch (Exception ex)
            {
                logger.WriteError(operationName + " failed: " + ex.ToString());
                return(false);
            }
            return(true);
        }
コード例 #4
0
        }                                         // This is True if the SGEN command line exceeds 32,000 characters and is therefore split into "SGenCommandLineParameters" and "SGenCommandLineParametersContinued".

        public override bool Execute()
        {
            ILogger logger        = new LoggerThatUsesTaskOutput(this);
            string  operationName = "C#/XAML for HTML5: SerializationAssembliesGenerator";

            try
            {
                // Retrieve the full path of sgen.exe:
                string sgenFullPath;
                if (!GeneratingSerializationAssemblies.TryGetLocationOfSGenExe(out sgenFullPath) ||
                    string.IsNullOrEmpty(sgenFullPath))
                {
                    throw new Exception("Could not find the file sgen.exe: please contact [email protected] or ignore this error by adding the following line to your CSPROJ file: <CSharpXamlForHtml5SkipSerializationAssemblies>True</CSharpXamlForHtml5SkipSerializationAssemblies>");
                }

                // Retrieve its directory:
                var sgenDirectoryLongPath = Path.GetDirectoryName(sgenFullPath);
                if (string.IsNullOrEmpty(sgenDirectoryLongPath))
                {
                    throw new Exception("Unable to generate short 8.3 path from long path: please report this issue to [email protected]");
                }

                //  Convert that directory to the short 8.3-filenames format, so that we don't need to surround the path with double quotes (which don't work with the MSBuild Exec tasc):
                SGenDirectory = ShortPathHelper.GetShortPathName(sgenDirectoryLongPath);

                // Generate command line parameters:
                string sgenCommandLineParameters;
                string sgenCommandLineParametersContinued;
                bool   sgenIsContinued;
                bool   isSuccess = GeneratingSerializationAssemblies.GenerateSgenCommandLineParameters(IntermediateOutputDirectory, SourceAssembly, new LoggerThatUsesTaskOutput(this), IsBridgeBasedVersion, out sgenCommandLineParameters, out sgenCommandLineParametersContinued, out sgenIsContinued);
                SGenCommandLineParameters          = sgenCommandLineParameters;
                SGenCommandLineParametersContinued = sgenCommandLineParametersContinued;
                SGenIsContinued = sgenIsContinued;

                return(isSuccess);
            }
            catch (ReflectionTypeLoadException ex)
            {
                logger.WriteError(operationName + " failed. " + Environment.NewLine + Environment.NewLine + "LOADER EXCEPTIONS:" + Environment.NewLine + Environment.NewLine + ConvertLoaderExceptionsToString(ex) + Environment.NewLine + Environment.NewLine + "GENERAL EXCEPTION:" + Environment.NewLine + Environment.NewLine + ex.ToString());
                return(false);
            }
            catch (Exception ex)
            {
                logger.WriteError(operationName + " failed : " + ex.ToString());
                return(false);
            }
        }
コード例 #5
0
        public override bool Execute()
        {
            ILogger logger        = new LoggerThatUsesTaskOutput(this);
            string  operationName = "C#/XAML for HTML5: SerializationAssembliesProcessor";

            try
            {
                string fileToIncludeInProject;
                bool   isSuccess = GeneratingSerializationAssemblies.ProcessSourceCode(IntermediateOutputDirectory, SGenIsContinued, logger, out fileToIncludeInProject);
                FileToIncludeInProject = fileToIncludeInProject;
                return(isSuccess);
            }
            catch (Exception ex)
            {
                logger.WriteError(operationName + " failed: " + ex.ToString());
                return(false);
            }
        }
コード例 #6
0
 public override bool Execute()
 {
     if (!string.IsNullOrEmpty(RequiredAssemblies))
     {
         ILogger logger        = new LoggerThatUsesTaskOutput(this);
         string  operationName = "C#/XAML for HTML5: AssemblyMissingReferenceChecker";
         try
         {
             return(CheckingThatNoAssemblyReferenceIsMissing.Check(References, RequiredAssemblies, logger));
         }
         catch (Exception ex)
         {
             logger.WriteError(operationName + " failed: " + ex.ToString());
             return(false);
         }
     }
     else
     {
         return(true);
     }
 }
コード例 #7
0
        public override bool Execute()
        {
            ILogger logger        = new LoggerThatUsesTaskOutput(this);
            string  operationName = "C#/XAML for HTML5: AssemblyAttributesGenerator";

            try
            {
                // Validate input strings:
                if (string.IsNullOrEmpty(OutputFile))
                {
                    throw new Exception(operationName + " failed because the output file argument is invalid.");
                }

                //------- DISPLAY THE PROGRESS -------
                logger.WriteMessage(operationName + " started.");

                // Generate attributes:
#if BRIDGE || CSHTML5BLAZOR
                string generatedCode = string.Format(@"
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was auto-generated by ""CSHTML5""
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
[assembly: global::CSHTML5.Internal.Attributes.CompilerVersionNumber(""{0}"")]
[assembly: global::CSHTML5.Internal.Attributes.CompilerVersionFriendlyName(""{1}"")]
[assembly: global::CSHTML5.Internal.Attributes.CompilerIsSLMigrationAttribute({2})]
[assembly: global::CSHTML5.Internal.Attributes.IntermediateOutputAbsolutePath(@""{3}"")]
[assembly: global::CSHTML5.Internal.Attributes.SettingsAttribute()]
",
                                                     VersionInformation.GetCurrentVersionNumber().ToString(),
                                                     VersionInformation.GetCurrentVersionFriendlyName(),
                                                     (this.IsSLMigration ? "true" : "false"),
                                                     IntermediateOutputAbsolutePath
                                                     );
#else
                string generatedCode = string.Format(@"
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was auto-generated by ""C#/XAML for HTML5""
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

[assembly: global::CompilerVersionNumber(""{0}"")]
[assembly: global::CompilerVersionFriendlyName(""{1}"")]
[assembly: global::CompilerIsSLMigration({2})]

[assembly: global::CSHTML5.Internal.Attributes.OutputRootPath(@""{3}"")]
[assembly: global::CSHTML5.Internal.Attributes.OutputAppFilesPath(@""{4}"")]
[assembly: global::CSHTML5.Internal.Attributes.OutputLibrariesPath(@""{5}"")]
[assembly: global::CSHTML5.Internal.Attributes.OutputResourcesPath(@""{6}"")]
[assembly: global::CSHTML5.Internal.Attributes.IntermediateOutputAbsolutePath(@""{7}"")]

[assembly: global::CSHTML5.Internal.Attributes.SettingsAttribute(GenerateJavaScriptDuringBuild = {8})]
"
                                                     ,
                                                     VersionInformation.GetCurrentVersionNumber().ToString(),
                                                     VersionInformation.GetCurrentVersionFriendlyName(),
                                                     (this.IsSLMigration ? "true" : "false"),
                                                     OutputRootPath,
                                                     OutputAppFilesPath,
                                                     OutputLibrariesPath,
                                                     OutputResourcesPath,
                                                     IntermediateOutputAbsolutePath,
                                                     (this.GenerateJavaScriptDuringBuild ? "true" : "false")
                                                     );
#endif
                // Create output directory:
                Directory.CreateDirectory(Path.GetDirectoryName(OutputFile));

                // Save output:
                using (StreamWriter outfile = new StreamWriter(OutputFile))
                {
                    outfile.Write(generatedCode);
                }

                //------- DISPLAY THE PROGRESS -------
                logger.WriteMessage(operationName + " completed.");

                return(true);
            }
            catch (Exception ex)
            {
                logger.WriteError(operationName + " failed: " + ex.ToString());
                return(false);
            }
        }