Exemple #1
0
 protected override HostObjectInitializationStatus InitializeHostObject()
 {
     if (base.HostObject != null)
     {
         using (RCWForCurrentContext <ICscHostObject> context = new RCWForCurrentContext <ICscHostObject>(base.HostObject as ICscHostObject))
         {
             ICscHostObject rCW = context.RCW;
             if (rCW != null)
             {
                 bool flag = this.InitializeHostCompiler(rCW);
                 if (rCW.IsDesignTime())
                 {
                     return(flag ? HostObjectInitializationStatus.NoActionReturnSuccess : HostObjectInitializationStatus.NoActionReturnFailure);
                 }
                 if (!base.HostCompilerSupportsAllParameters || this.UseAlternateCommandLineToolToExecute())
                 {
                     if (!base.CheckAllReferencesExistOnDisk())
                     {
                         return(HostObjectInitializationStatus.NoActionReturnFailure);
                     }
                     base.UsedCommandLineTool = true;
                     return(HostObjectInitializationStatus.UseAlternateToolToExecute);
                 }
                 if (flag)
                 {
                     return(rCW.IsUpToDate() ? HostObjectInitializationStatus.NoActionReturnSuccess : HostObjectInitializationStatus.UseHostObjectToExecute);
                 }
                 return(HostObjectInitializationStatus.NoActionReturnFailure);
             }
             base.Log.LogErrorWithCodeFromResources("General.IncorrectHostObject", new object[] { "Csc", "ICscHostObject" });
         }
     }
     base.UsedCommandLineTool = true;
     return(HostObjectInitializationStatus.UseAlternateToolToExecute);
 }
Exemple #2
0
        /// <summary>
        /// This method will get called during Execute() if a host object has been passed into the Vbc
        /// task.  Returns one of the following values to indicate what the next action should be:
        ///     UseHostObjectToExecute          Host compiler exists and was initialized.
        ///     UseAlternateToolToExecute       Host compiler doesn't exist or was not appropriate.
        ///     NoActionReturnSuccess           Host compiler was already up-to-date, and we're done.
        ///     NoActionReturnFailure           Bad parameters were passed into the task.
        /// </summary>
        /// <owner>RGoel</owner>
        protected override HostObjectInitializationStatus InitializeHostObject()
        {
            if (this.HostObject != null)
            {
                // When the host object was passed into the task, it was passed in as a generic
                // "Object" (because ITask interface obviously can't have any Vbc-specific stuff
                // in it, and each task is going to want to communicate with its host in a unique
                // way).  Now we cast it to the specific type that the Vbc task expects.  If the
                // host object does not match this type, the host passed in an invalid host object
                // to Vbc, and we error out.

                // NOTE: For compat reasons this must remain IVbcHostObject
                // we can dynamically test for smarter interfaces later..
                using (RCWForCurrentContext<IVbcHostObject> hostObject = new RCWForCurrentContext<IVbcHostObject>(this.HostObject as IVbcHostObject))
                {
                    IVbcHostObject vbcHostObject = hostObject.RCW;

                    if (vbcHostObject != null)
                    {
                        bool hostObjectSuccessfullyInitialized = InitializeHostCompiler(vbcHostObject);

                        // If we're currently only in design-time (as opposed to build-time),
                        // then we're done.  We've initialized the host compiler as best we
                        // can, and we certainly don't want to actually do the final compile.
                        // So return true, saying we're done and successful.
                        if (vbcHostObject.IsDesignTime())
                        {
                            // If we are design-time then we do not want to continue the build at 
                            // this time.
                            return hostObjectSuccessfullyInitialized ?
                                HostObjectInitializationStatus.NoActionReturnSuccess :
                                HostObjectInitializationStatus.NoActionReturnFailure;
                        }

                        // Roslyn doesn't support using the host object for compilation

                        // Since the host compiler has refused to take on the responsibility for this compilation,
                        // we're about to shell out to the command-line compiler to handle it.  If some of the
                        // references don't exist on disk, we know the command-line compiler will fail, so save
                        // the trouble, and just throw a consistent error ourselves.  This allows us to give
                        // more information than the compiler would, and also make things consistent across
                        // Vbc / Csc / etc.  Actually, the real reason is bug 275726 (ddsuites\src\vs\env\vsproject\refs\ptp3).
                        // This suite behaves differently in localized builds than on English builds because 
                        // VBC.EXE doesn't localize the word "error" when they emit errors and so we can't scan for it.
                        if (!CheckAllReferencesExistOnDisk())
                        {
                            return HostObjectInitializationStatus.NoActionReturnFailure;
                        }

                        // The host compiler doesn't support some of the switches/parameters
                        // being passed to it.  Therefore, we resort to using the command-line compiler
                        // in this case.
                        UsedCommandLineTool = true;
                        return HostObjectInitializationStatus.UseAlternateToolToExecute;
                    }
                    else
                    {
                        Log.LogErrorWithCodeFromResources("General_IncorrectHostObject", "Vbc", "IVbcHostObject");
                    }
                }
            }


            // No appropriate host object was found.
            UsedCommandLineTool = true;
            return HostObjectInitializationStatus.UseAlternateToolToExecute;
        }
 protected override HostObjectInitializationStatus InitializeHostObject()
 {
     if (base.HostObject != null)
     {
         using (RCWForCurrentContext<ICscHostObject> context = new RCWForCurrentContext<ICscHostObject>(base.HostObject as ICscHostObject))
         {
             ICscHostObject rCW = context.RCW;
             if (rCW != null)
             {
                 bool flag = this.InitializeHostCompiler(rCW);
                 if (rCW.IsDesignTime())
                 {
                     return (flag ? HostObjectInitializationStatus.NoActionReturnSuccess : HostObjectInitializationStatus.NoActionReturnFailure);
                 }
                 if (!base.HostCompilerSupportsAllParameters || this.UseAlternateCommandLineToolToExecute())
                 {
                     if (!base.CheckAllReferencesExistOnDisk())
                     {
                         return HostObjectInitializationStatus.NoActionReturnFailure;
                     }
                     base.UsedCommandLineTool = true;
                     return HostObjectInitializationStatus.UseAlternateToolToExecute;
                 }
                 if (flag)
                 {
                     return (rCW.IsUpToDate() ? HostObjectInitializationStatus.NoActionReturnSuccess : HostObjectInitializationStatus.UseHostObjectToExecute);
                 }
                 return HostObjectInitializationStatus.NoActionReturnFailure;
             }
             base.Log.LogErrorWithCodeFromResources("General.IncorrectHostObject", new object[] { "Csc", "ICscHostObject" });
         }
     }
     base.UsedCommandLineTool = true;
     return HostObjectInitializationStatus.UseAlternateToolToExecute;
 }
Exemple #4
0
        /// <summary>
        /// This method will get called during Execute() if a host object has been passed into the Csc
        /// task.  Returns one of the following values to indicate what the next action should be:
        ///     UseHostObjectToExecute          Host compiler exists and was initialized.
        ///     UseAlternateToolToExecute       Host compiler doesn't exist or was not appropriate.
        ///     NoActionReturnSuccess           Host compiler was already up-to-date, and we're done.
        ///     NoActionReturnFailure           Bad parameters were passed into the task.
        /// </summary>
        override protected HostObjectInitializationStatus InitializeHostObject()
        {
            if (this.HostObject != null)
            {
                // When the host object was passed into the task, it was passed in as a generic
                // "Object" (because ITask interface obviously can't have any Csc-specific stuff
                // in it, and each task is going to want to communicate with its host in a unique
                // way).  Now we cast it to the specific type that the Csc task expects.  If the
                // host object does not match this type, the host passed in an invalid host object
                // to Csc, and we error out.

                // NOTE: For compat reasons this must remain ICscHostObject
                // we can dynamically test for smarter interfaces later..
                using (RCWForCurrentContext <ICscHostObject> hostObject = new RCWForCurrentContext <ICscHostObject>(this.HostObject as ICscHostObject))
                {
                    ICscHostObject cscHostObject = hostObject.RCW;

                    if (cscHostObject != null)
                    {
                        bool hostObjectSuccessfullyInitialized = InitializeHostCompiler(cscHostObject);

                        // If we're currently only in design-time (as opposed to build-time),
                        // then we're done.  We've initialized the host compiler as best we
                        // can, and we certainly don't want to actually do the final compile.
                        // So return true, saying we're done and successful.
                        if (cscHostObject.IsDesignTime())
                        {
                            // If we are design-time then we do not want to continue the build at
                            // this time.
                            return(hostObjectSuccessfullyInitialized ?
                                   HostObjectInitializationStatus.NoActionReturnSuccess :
                                   HostObjectInitializationStatus.NoActionReturnFailure);
                        }

                        if (!this.HostCompilerSupportsAllParameters || UseAlternateCommandLineToolToExecute())
                        {
                            // Since the host compiler has refused to take on the responsibility for this compilation,
                            // we're about to shell out to the command-line compiler to handle it.  If some of the
                            // references don't exist on disk, we know the command-line compiler will fail, so save
                            // the trouble, and just throw a consistent error ourselves.  This allows us to give
                            // more information than the compiler would, and also make things consistent across
                            // Vbc / Csc / etc.
                            // This suite behaves differently in localized builds than on English builds because
                            // VBC.EXE doesn't localize the word "error" when they emit errors and so we can't scan for it.
                            if (!CheckAllReferencesExistOnDisk())
                            {
                                return(HostObjectInitializationStatus.NoActionReturnFailure);
                            }

                            // The host compiler doesn't support some of the switches/parameters
                            // being passed to it.  Therefore, we resort to using the command-line compiler
                            // in this case.
                            UsedCommandLineTool = true;
                            return(HostObjectInitializationStatus.UseAlternateToolToExecute);
                        }

                        // Ok, by now we validated that the host object supports the necessary switches
                        // and parameters.  Last thing to check is whether the host object is up to date,
                        // and in that case, we will inform the caller that no further action is necessary.
                        if (hostObjectSuccessfullyInitialized)
                        {
                            return(cscHostObject.IsUpToDate() ?
                                   HostObjectInitializationStatus.NoActionReturnSuccess :
                                   HostObjectInitializationStatus.UseHostObjectToExecute);
                        }
                        else
                        {
                            return(HostObjectInitializationStatus.NoActionReturnFailure);
                        }
                    }
                    else
                    {
                        Log.LogErrorWithCodeFromResources("General.IncorrectHostObject", "Csc", "ICscHostObject");
                    }
                }
            }

            // No appropriate host object was found.
            UsedCommandLineTool = true;
            return(HostObjectInitializationStatus.UseAlternateToolToExecute);
        }