Fluent API for the .NET Framework (used by the O2 Platform)
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
FluentSharp.AST @ ee933b7
FluentSharp.AspNet_MVC @ 7d6da30
FluentSharp.CoreLib @ 41dffaf
FluentSharp.HtmlAgilityPack @ 5836992
FluentSharp.HtmlAgilityPack.WinForms @ 2af32e4
FluentSharp.Moq @ 360588d
FluentSharp.MsBuild @ 7aec8d8
FluentSharp.NGit @ 3b2b2a5
FluentSharp.NUnit @ ffcce2d
FluentSharp.O2Platform @ 33ed1f2
FluentSharp.REPL @ 4dab426
FluentSharp.Roslyn @ d070911
FluentSharp.WPF @ 8e5aa24
FluentSharp.Web @ c0eb5a6
FluentSharp.Web_4_5 @ d942f63
FluentSharp.WinForms @ 3c60d77
FluentSharp.WinFormsUI @ ad103c0
FluentSharp.Xml @ 54d20ca
FluentSharp.Zip @ 9cb28d3
FluentSharp_Fork.CassiniDev @ 830a735
FluentSharp_Fork.SharpDevelopEditor @ 91e304d
FluentSharp_Fork.WatiN @ cc70e86


FluentSharp Build Status

FluentSharp are a number of Open Source .Net APIs that dramatically simplifies the use of .NET Framework APIs.

They makes extensive use of .NET ExtensionMethods and reduces the amount of code required (while making the original code more readable).

By now, a large part of the .NET Framework is covered by FluentSharp ExtensionMethods (String, Xml, IO, WinForms, Reflection, etc..).

As an example, the FluentSharp .NET Reflection ExtensionMethods are very powerful, since they provide (via user-friendly methods) full access to .NET classes, methods, properties, fields and enums (regardless of their public/private status).

How to clone and compile FluentSharp in VisualStudio 2013

What is the OWASP O2 Platform

The FluentSharp APIs are at the core of the OWASP O2 Platform which is usually described like this: 'The O2 platform represents a new paradigm for how to perform, document and distribute Web Application security reviews. O2 is designed to Automate Security Consultants Knowledge and Workflows and to Allow non-security experts to access and consume Security Knowledge'


You can get all FluentSharp APIs via Nuget. For example FluentSharp.WatiN can be installed by typing this command in the VisualStudio Package Manager Console Install-Package FluentSharp.WatiN

Here are the main packages:

Full list of published Nuget packages is here

Code Samples

Here is where you can find tons of code samples and O2 releated posts


Mailing list and issues list

If you want to ask questions about the O2 Platform or FluetnSHarp please use the https://groups.google.com/a/owasp.org/forum/#!forum/o2-platform.

If you want to open an issue or want to help, please take a look at the issues currently opened and see if you can provide a fix for them:

FluentSharp in Action: Example 1

For example if you want to list all files from a particular directory you can just execute:


...if you wanted all files in all directories (i.e. recursive search), you would use:


... all *.cs files:


... all *.cs and *.h2 files:

@"C:\O2".files(true,"*.cs" ,"*.h2");

... show files in treeView:

new TreeView().add_Nodes(@"C:\O2".files(true,"*.cs","*.h2"));

...show results in a popupWindow (i.e. in Windows Form) with treeView showing files:

"New popup Window with TreeView".popupWindow().add_TreeView().add_Nodes(@"C:\O2".files(true,"*.cs","*.h2"));

... swow in popupWindow with the TreeVIew with files and a source code viewer that shows the selected file:

var targetFolder = @"C:\O2";
var sourceCodeViewer ="View C# and H2 files in folder".popupWindow()
		.add_Nodes(targetFolder.files(true,"*.cs","*.h2"), (file)=>file.fileName())

The key objective of this style of programming is to make it really easy read and understand what is going on.

The way these extension methods are written is to focus on the Intent of the action, and then hide all technology behind the scenes.

For example in the last example, this code

.add_TreeView().add_Nodes(targetFolder ,"*.cs","*.h2"), (file)=>file.fileName());

can be further refactored to:

.add_TreeView().add_Files(targetFolder ,"*.cs","*.h2");

FluentSharp in Action: Example 2

Here is a more complete example that shows these FluentSharp APIs in action (inside VisualStudio):

using System;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using FluentSharp.O2.Views.ASCX.classes.MainGUI;
using FluentSharp.O2.Kernel.ExtensionMethods;
using FluentSharp.O2.DotNetWrappers.ExtensionMethods;

namespace FluentSharp_Test
    class Program
        static void Main(string[] args)
            var topPanel = O2Gui.open<Panel>("FluentSharp - Simple Test", 1000, 300);            
            //TextBox that will hold the data
            var textBox = topPanel.add_GroupBox("TextBox with selected data").add_TextArea();

            //Left-Hand-side TreeView with filenames (when click shows content on TextBox)
            var folder = @"C:\O2\Demos\FluentSharp";
                   .add_GroupBox("Files in Folder")
                   .add_Nodes(folder.files("*.cs", true))
                   .afterSelect<string>((file) => textBox.set_Text(file.fileContents()))

            //Right-Hand-side TreeView with types from an Assembly (when click shows list of methods on TextBox)
            var assemblyToShow = "FluentSharp_O2.dll";
                   .add_GroupBox("Types in Assembly")
                   .afterSelect<Type>((type) =>
                       		textBox.set_Text("Methods in Type: {0}".line().format(type.fullName()));
	                        foreach (var method in type.methods())
                           		textBox.append_Line("  -  {0}".format(method.Name));                 	 

The code above when executed will look like this:

Here is an example of how to use the FluentSharp REPL (also part of the O2 Development Environment) to develop and quickly execute the script above:

GitHub Repositories

There a number of GitHub repositories used to host the multiple parts of the FluentSharp and O2 Platform components:

There is also the https://github.com/o2platform/Book_WebAutomation which contains the first pass at creating an book about the O2 Platform and WatiN APIs

Why Fluent?

Rational and References for Fluent Interfaces, Fluent Programming

The O2 Platform scripting environment makes extensive use of C# 3.0 features like Linq, Lambda and ExtensionMethods. Here is a great article that explains how these technologies work and provide C# code samples of how to use them: http://msdn.microsoft.com/en-us/library/bb308959.aspx . Some of these already have their representation in O2, for exampe the 'Where' function has an equivalent lowercase 'where' ExtensionMethod , with the O2 version handling the checking if the original data is null, and returning a List (instead of an Enumerable)

I found the 'Fluent' concept when I was looking at JQuery and noticed that its API (Philosophy) looked a lot like O2's API.

JQuery calls what it does 'Fluent API' and I had a look at what it means and found what I'm doing with O2's Scripting is a lot like it. Here are some references for past 'Fluent' threads:

What is interesting about the links above is that:

a) they are a bit old (circa 2008) and b) they don't mention .Net's extension methods (which for me are the KEY reason why I went the 'fluent way' in O2's API). The other thing that I do very differently in O2, is that I don't create special 'Fluent Interface' classes, I just extend the ones that already exist.