Giter Club home page Giter Club logo

Comments (2)

rainersigwald avatar rainersigwald commented on August 17, 2024 1

This is a consequence of the ITask interface. Tasks can return success or failure by the bool return value of Execute(), and independently they can log errors. Unfortunately, that means you can say

Log.LogError("Catastrophic failure");
return true; // "Task succeeded"

And unfortunately that's basically what we do for the fragment type of inline code (add return true; after the user-specified code).

We should consider adopting the preferred pattern (return !Log.HasLoggedError;) in our generation around here:

private static void CreateExecuteMethodFromFragment(CodeTypeDeclaration codeTypeDeclaration, string executeCode)
{
var executeMethod = new CodeMemberMethod
{
Name = "Execute",
Attributes = MemberAttributes.Override | MemberAttributes.Public
};
executeMethod.Statements.Add(new CodeSnippetStatement(executeCode));
executeMethod.ReturnType = new CodeTypeReference(typeof(Boolean));
executeMethod.Statements.Add(new CodeMethodReturnStatement(new CodeFieldReferenceExpression(null, "_Success")));
codeTypeDeclaration.Members.Add(executeMethod);
}

and also in RoslynCodeTaskFactory

if (taskInfo.CodeType == RoslynCodeTaskFactoryCodeType.Fragment)
{
CodeMemberProperty successProperty = CreateProperty(codeTypeDeclaration, "Success", typeof(bool), true);
CodeMemberMethod executeMethod = new CodeMemberMethod
{
Name = "Execute",
// ReSharper disable once BitwiseOperatorOnEnumWithoutFlags
Attributes = MemberAttributes.Override | MemberAttributes.Public,
ReturnType = new CodeTypeReference(typeof(Boolean))
};
executeMethod.Statements.Add(new CodeSnippetStatement(taskInfo.SourceCode));
executeMethod.Statements.Add(new CodeMethodReturnStatement(new CodePropertyReferenceExpression(null, successProperty.Name)));
codeTypeDeclaration.Members.Add(executeMethod);

from msbuild.

KirillOsenkov avatar KirillOsenkov commented on August 17, 2024

good bug!

from msbuild.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.