Create extension method of Fiddler.Session

2 posts, 1 answers
  1. Peter
    Peter avatar
    5 posts
    Member since:
    Dec 2015

    Posted 28 Dec 2015 Link to this post

    I've made a method which interacts with Fiddler in C#. The code looks like this:

    using Fiddler; 
    namespace SmartMocks
    {
        public class SmartMocks
        {
            public static void SmartMock(Session oSession, string directoryPath)
            { //etc...
    After referencing the DLL in Fiddler > Options > Extensions, I add the following to the top of FiddlerScript:

    import SmartMocks;

    And then I can call the function in FiddlerScript like this:

    SmartMocks.SmartMocks.SmartMock(oSession, "C:\\SomeFile.txt");

    This works fine. However, I'd like to make SmartMock be an extension method of Fiddler.Session, so that I can use this nicer-looking syntax instead in FiddlerScript:

    oSession.SmartMock("C:\\SomeFile.txt");

    I'm not familiar with JScript.NET and how it handles references, so I've been having trouble adding this method to Fiddler.Session. I tried changing the code to an extension like this:

    namespace SmartMocks
    {
        public static class SmartMocks
        {
            public static void SmartMock(this Session oSession, string directoryPath)
            {

    However, when compiling FiddlerScript, calling "oSession.SmartMock("C:\\SomeFile.txt")" gives the error "Objects of type 'Fiddler.Session' do not have such a member".

    My question is:

    • How do you create an extension method to a class (like Fiddler.Session) in JScript.NET?
  2. Answer
    Eric Lawrence
    Admin
    Eric Lawrence avatar
    833 posts

    Posted 29 Dec 2015 Link to this post

    Hello, Peter--

    As far as I know, extension methods are syntactic sugar supported by the compiler, and JScript.NET has no support for them. If you find out otherwise, please do let me know.

    When I use Fiddler's extension methods for strings (e.g. OICEndsWithAny()) I have to use the basic syntax, e.g.

       StringExtensions.OICEndsWithAny(sMIMEtype, arrMIMEs);

    Regards,
    Eric Lawrence
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top