Convert Figma logo to code with AI

UiPath logoCoreWF

WF runtime ported to work on .NET 6

1,134
217
1,134
27

Top Related Projects

15,122

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.

2,733

Cecil is a library to inspect, modify and create .NET programs and libraries.

19,150

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.

Source from the Microsoft .NET Reference Source that represent a subset of the .NET Framework

11,116

Mono open source ECMA CLI, C# and .NET implementation.

12,805

CoreCLR is the runtime for .NET Core. It includes the garbage collector, JIT compiler, primitive data types and low-level classes.

Quick Overview

CoreWF is an open-source port of the Windows Workflow Foundation (WF) runtime to .NET Core and .NET Standard. It aims to provide a workflow engine that can be used across different platforms, enabling developers to build and execute workflows in .NET applications outside of the Windows ecosystem.

Pros

  • Cross-platform compatibility, allowing workflow execution on various operating systems
  • Seamless integration with existing .NET Core and .NET Standard projects
  • Active development and community support
  • Maintains compatibility with many features from the original Windows Workflow Foundation

Cons

  • Limited documentation compared to the original Windows Workflow Foundation
  • Some advanced features from WF may not be fully implemented or supported
  • Potential learning curve for developers not familiar with workflow concepts
  • May require additional effort to migrate existing WF projects to CoreWF

Code Examples

  1. Creating a simple workflow:
using System.Activities;

var workflow = new Sequence
{
    Activities =
    {
        new WriteLine { Text = "Hello, CoreWF!" },
        new WriteLine { Text = "This is a simple workflow." }
    }
};

WorkflowInvoker.Invoke(workflow);
  1. Using variables in a workflow:
var workflow = new Sequence
{
    Variables = { new Variable<string>("name") },
    Activities =
    {
        new Assign<string>
        {
            To = new OutArgument<string>(ctx => ctx.GetVariable<string>("name")),
            Value = new InArgument<string>("John Doe")
        },
        new WriteLine
        {
            Text = new InArgument<string>(ctx => $"Hello, {ctx.GetVariable<string>("name")}!")
        }
    }
};

WorkflowInvoker.Invoke(workflow);
  1. Using a custom activity:
public class GreetingActivity : CodeActivity
{
    public InArgument<string> Name { get; set; }

    protected override void Execute(CodeActivityContext context)
    {
        var name = Name.Get(context);
        Console.WriteLine($"Greetings, {name}!");
    }
}

var workflow = new Sequence
{
    Activities =
    {
        new GreetingActivity { Name = "Alice" },
        new GreetingActivity { Name = "Bob" }
    }
};

WorkflowInvoker.Invoke(workflow);

Getting Started

  1. Install the CoreWF NuGet package:

    dotnet add package CoreWF
    
  2. Add the necessary using statements to your C# file:

    using System.Activities;
    using System.Activities.Statements;
    
  3. Create and run a simple workflow:

    var workflow = new Sequence
    {
        Activities =
        {
            new WriteLine { Text = "Hello, CoreWF!" }
        }
    };
    
    WorkflowInvoker.Invoke(workflow);
    

Competitor Comparisons

15,122

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.

Pros of runtime

  • Broader scope, covering the entire .NET runtime and core libraries
  • Larger community and more frequent updates
  • Official Microsoft support and integration with .NET ecosystem

Cons of runtime

  • More complex and harder to contribute to due to its size
  • May include unnecessary components for workflow-specific use cases
  • Steeper learning curve for developers focused solely on workflow functionality

Code Comparison

CoreWF:

Activity workflow = new Sequence
{
    Activities = 
    {
        new WriteLine { Text = "Hello from CoreWF!" }
    }
};

runtime:

using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;

await Host.CreateDefaultBuilder(args)
    .ConfigureServices((hostContext, services) => {
        // Configure services
    })
    .RunConsoleAsync();

Summary

CoreWF is a focused workflow engine, while runtime is a comprehensive .NET runtime implementation. CoreWF offers simplicity and workflow-specific features, whereas runtime provides a complete .NET development environment with broader capabilities. Choose CoreWF for workflow-centric projects and runtime for full-scale .NET applications.

2,733

Cecil is a library to inspect, modify and create .NET programs and libraries.

Pros of Cecil

  • Focused on .NET assembly manipulation and inspection
  • Lightweight and efficient for working with IL code
  • Widely used and battle-tested in many projects

Cons of Cecil

  • Limited scope compared to CoreWF's workflow capabilities
  • Requires more low-level knowledge of .NET internals
  • Less suitable for high-level business process modeling

Code Comparison

Cecil (assembly manipulation):

var assembly = AssemblyDefinition.ReadAssembly("MyAssembly.dll");
var type = assembly.MainModule.Types.First(t => t.Name == "MyClass");
var method = type.Methods.First(m => m.Name == "MyMethod");

CoreWF (workflow definition):

var workflow = new Sequence
{
    Activities =
    {
        new WriteLine { Text = "Hello World" },
        new Delay { Duration = TimeSpan.FromSeconds(1) }
    }
};

Summary

Cecil is a powerful library for .NET assembly manipulation, while CoreWF focuses on workflow creation and execution. Cecil is more suitable for low-level bytecode analysis and modification, whereas CoreWF is better for modeling business processes and complex workflows. The choice between them depends on the specific requirements of your project.

19,150

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.

Pros of Roslyn

  • Comprehensive C# and Visual Basic compiler platform
  • Extensive API for code analysis and manipulation
  • Large, active community and Microsoft backing

Cons of Roslyn

  • Steeper learning curve due to complexity
  • Larger codebase and resource requirements
  • May be overkill for simpler workflow scenarios

Code Comparison

Roslyn (C# syntax analysis):

SyntaxTree tree = CSharpSyntaxTree.ParseText("class Program { }");
var root = (CompilationUnitSyntax)tree.GetRoot();
var classDeclaration = root.DescendantNodes().OfType<ClassDeclarationSyntax>().First();

CoreWF (workflow definition):

var workflow = new Sequence
{
    Activities = { new WriteLine { Text = "Hello, World!" } }
};

Summary

Roslyn is a powerful compiler platform for .NET languages, offering extensive capabilities for code analysis and manipulation. CoreWF, on the other hand, focuses on workflow management and execution. While Roslyn provides more comprehensive language tools, CoreWF offers a simpler approach for defining and running workflows. The choice between them depends on the specific requirements of your project, with Roslyn being better suited for complex language-related tasks and CoreWF for workflow-centric applications.

Source from the Microsoft .NET Reference Source that represent a subset of the .NET Framework

Pros of referencesource

  • Comprehensive source code for .NET Framework, providing insights into core functionality
  • Maintained by Microsoft, ensuring high-quality and official implementation
  • Covers a wide range of .NET libraries and components

Cons of referencesource

  • Not actively developed or updated, as it's a reference for older .NET Framework versions
  • Lacks modern .NET Core and .NET 5+ features and optimizations
  • May contain legacy code that's no longer relevant in newer .NET implementations

Code Comparison

referencesource (System.Activities):

public sealed class Workflow : Activity, IPropertyLocationReferenceEnvironment
{
    internal const string WorkflowInstancePropertyName = "WorkflowInstance";
    internal const string WorkflowHostPropertyName = "WorkflowHost";
    internal const string WorkflowEnvironmentPropertyName = "WorkflowEnvironment";
}

CoreWF:

public sealed class WorkflowApplication
{
    public WorkflowApplication(Activity workflow)
    {
        this.Initialize(workflow, null, null, null);
    }
}

The code snippets show different approaches to workflow implementation. referencesource focuses on the Workflow class within the Activity framework, while CoreWF emphasizes the WorkflowApplication class for managing workflow execution.

11,116

Mono open source ECMA CLI, C# and .NET implementation.

Pros of mono

  • Broader scope and functionality as a complete .NET framework implementation
  • Longer development history and larger community support
  • Cross-platform compatibility for a wide range of .NET applications

Cons of mono

  • Larger codebase and potentially more complex to contribute to
  • May have slower release cycles due to its comprehensive nature
  • Potentially higher resource usage for simpler applications

Code Comparison

mono:

public class HelloWorld
{
    public static void Main(string[] args)
    {
        Console.WriteLine("Hello World!");
    }
}

CoreWF:

public class HelloWorldActivity : CodeActivity
{
    protected override void Execute(CodeActivityContext context)
    {
        Console.WriteLine("Hello World!");
    }
}

The code examples highlight the difference in focus between the two projects. mono provides a full .NET implementation, allowing for traditional console applications, while CoreWF is specifically designed for workflow-based activities.

CoreWF offers a more specialized solution for workflow-related tasks, which can be advantageous for projects primarily focused on workflow management. However, mono's broader scope makes it suitable for a wider range of .NET applications and development scenarios.

12,805

CoreCLR is the runtime for .NET Core. It includes the garbage collector, JIT compiler, primitive data types and low-level classes.

Pros of CoreCLR

  • Broader scope and functionality as the core runtime for .NET
  • Larger community and more frequent updates
  • More extensive documentation and resources

Cons of CoreCLR

  • Higher complexity and steeper learning curve
  • Larger codebase, potentially harder to navigate for specific workflow features
  • May include unnecessary components for projects focused solely on workflows

Code Comparison

CoreCLR (runtime initialization):

var runtimeConfig = new ConfigurationBuilder()
    .AddCommandLine(args)
    .Build();
var host = new HostBuilder()
    .UseContentRoot(Directory.GetCurrentDirectory())
    .UseConfiguration(runtimeConfig)
    .Build();

CoreWF (workflow definition):

var workflow = new Sequence
{
    Activities =
    {
        new WriteLine { Text = "Hello World!" }
    }
};
WorkflowInvoker.Invoke(workflow);

Summary

CoreCLR is a comprehensive runtime for .NET applications, while CoreWF focuses specifically on Windows Workflow Foundation functionality. CoreCLR offers broader capabilities but may be overkill for projects centered around workflows. CoreWF provides a more targeted solution for workflow-centric applications but with a narrower scope and potentially fewer resources.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Build Status

CoreWF

A port of the Windows Workflow Foundation (WF) runtime to .NET 6. It is licensed under the MIT License.

This is not an official Microsoft release of WF on .NET 6. CoreWF is a derivative work of Microsoft's copyrighted Windows Workflow Foundation.

WF Overview

Workflows are multi-step processes composed of activities. Activities are single-purpose elements that can be composed of other activities. Workflows have only one root activity in the same way that an XML document has only one root element.

Developers can create workflows in code:

var helloWorldActivity = new Sequence()
{
    Activities =
    {
        new WriteLine
        {
            Text = "Hello World!"
        }
    }
};

The workflow can be run with the following code:

System.Activities.WorkflowInvoker.Invoke(helloWorldActivity);

The similarity of workflow/activity concepts to XML's document/element concepts means it's possible to write workflows in XML; specifically, an extension of XML called XAML . The "Hello World!" workflow from above can be written as:

<Activity 
 x:Class="WorkflowConsoleApplication1.HelloWorld"
 xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Sequence>
    <WriteLine Text="Hello World!" />
  </Sequence>
</Activity>

The XAML workflow can be loaded in CoreWF through ActivityXamlServices:

var helloWorldActivity = ActivityXamlServices.Load(new StringReader(xamlString));
System.Activities.WorkflowInvoker.Invoke(helloWorldActivity);

WF in the .NET Framework includes a visual, drag-and-drop designer for workflows that produces XAML. The "Hello World!" workflow looks like this in the designer:

Hello World! workflow in WF designer

The designer experience is not part of CoreWF but the XAML produced by the designer can be run in CoreWF (with some limitations). The WF designer experience is available in Visual Studio 2019 by enabling the "Windows Workflow Foundation" individual component in the Visual Studio Installer.

Target Frameworks

CoreWF targets .NET 6 and .NET 6 Windows. The .NET Windows target uses the System.Xaml included in the .NET Desktop Runtime. To use CoreWF on non-Windows runtimes, use the portable .NET 6 target. This is possible because CoreWF includes a copy of the System.Xaml code.

Usage

To add this library to your project, use the NuGet package.

Debug using Source Link

Preview builds setup

MyGet (dev)

Contributing

Check out the contributing guide for information on how to help CoreWF.

Code of Conduct

This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information see the .NET Foundation Code of Conduct.

.NET Foundation

This project is supported by the .NET Foundation.