GithubHelp home page GithubHelp logo

omarelabd / objectexporter Goto Github PK

View Code? Open in Web Editor NEW
261.0 22.0 84.0 75.34 MB

Object Exporter lets you export out an object while debugging in Visual Studio, the object can be serialized in either C#, JSON or XML.

License: GNU General Public License v3.0

C# 100.00%
debugging testing-tools regression-testing visual-studio dumper exporter

objectexporter's Introduction

Object Exporter

Join the chat at https://gitter.im/OmarElabd/ObjectExporter Build status

Object Exporter lets you export out an object while debugging in Visual Studio. Currently supported output formats are: C# Object Initialization Code, JSON and XML.

Release Notes

[1.7.0] (https://raw.githubusercontent.com/OmarElabd/ObjectExporter/master/ObjectExporter.VsPackage/Documentation/Release%20Notes.txt)

Use Cases

  1. Persisting an object state for debugging comparisons.

  2. Searching for information within objects.

  3. Generating C# object initialization code for unit testing.

Output

The currently supported output formats are: C# Object Initialization Code, JSON and XML.

Instructions

Object Exporter is accessed through the tools menu and is only visible when you are debugging and stopped at a breakpoint.

Select from tool menu

Once the menu option is selected a dialog is shown with settings for the Object Export.

Object exporter has two modes for selecting objects to export, one is by selecting from a checklist which is populated with your locals.

Select locals

The other mode is by writing a custom expression as you would in the watch window.

Custom Expression

Once an object is written or selected, object exporter will attempt to calculate it's depth in the background. This depth will give you an indication of what cutoff would need to be specified to export the entire object. Note some objects may contain circular references.

Select Locals with calculated depth

Once your objects and settings are selected, you may export them in your desired format. A dialog will be displayed with the generated ouput for each of your objects.

C#:

Generated C#

JSON:

Generated JSON

XML:

Generated XML

Settings

Object exporter settings is access through Tools -> Options -> Object Exporter

Settings

Powered By

Object Exporter is powered by RayGun.

Raygun

objectexporter's People

Contributors

gitter-badger avatar iangregory avatar jnyrup avatar omarelabd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

objectexporter's Issues

Add preprocessing for Expression COM Objects to be copied into new Type

Pros:

  1. Errors can be detected earlier on
  2. Cleaner Code
    a. Can move all the static methods into new Expression class
    b. Can now use foreach loops etc...
    c. Can now write some unit tests (Most important). And can use object exporter to export the project to test.

Cons:

  1. Potentially longer execution time

Note: we are to some extent doing this already in the t4 templates.

Object initializer missing property assignemnt

Using VS2015 and C#6

Code generated:

var response = new Xyz.DomainObjects.OrderResponse
{
    new Xyz.DomainObjects.OrderDetails
    {
    ...

Should be:

var response = new Xyz.DomainObjects.OrderResponse
{
    OrderDetails = new Xyz.DomainObjects.OrderDetails
    {
    ...

Support for VS 2010

In progress.

Note: Version of VS 2010, will not have support for the async await that is utilized in the vs 2012 and 2013 versions. Background worker or synchronous methods will be used instead.

Private objects are included even if "Exclude Private" is selected

Example of what is produced:
AcquiredImageData = new System.Collections.Generic.List<MedAvail.Data.Messages.Dispense.AcquiredImageData>
{
},
BarCodeSummary = new System.Collections.Generic.List<MedAvail.Data.Messages.Dispense.BarCodeData>
{
},

...
_AcquiredImageData = new System.Collections.Generic.List<MedAvail.Data.Messages.Dispense.AcquiredImageData>
{
},
_BarCodeSummary = new System.Collections.Generic.List<MedAvail.Data.Messages.Dispense.BarCodeData>
{
}
...

Add Support for Nullable Guids

Reported by @pawciut:

In version 1.2.4 nullable Guids are incorrect. They are present at C# code as
"new System.Guid?{ }" without property name to be assigned to.

example:

TypeCode = null,
new System.Guid?
{
},
TypeName = null,
Version = null,

or something like this:

Description = "Status główny",
DocumentId
Id
new System.Guid?
{
},
new System.Guid?
{
},

Debugger Values appearing in Variables

Depending on how the code was executed, the value of a variable may be a warning message from the compiler.

List:

  1. A type or generic instantiation needed to evaluate this expression does not exist in the process being debugged

Issues when exporting a collection of objects (typeof object) with different types

Given some collection of type object, the collection members may be a different type other than object. However the code generated is not accurate.

Example:

items = new object[]
{
    new object {Some.Type}
    {
    }
}

when it should be:

items = new object[]
{
    new Some.Type
    {
    }
}

*Note: There are some special considerations for exporting value types within an object collection

 object[] obj = new object[]
            {
                new Form(),
                "Hello",
                2,
                DateTime.Now,
                22.24f,
                1.0m
            };

Add option to ignore Entity Framework Proxy objects

EF generates child members with types of System.Data.Entity.DynamicProxies
.Blog_5E43C6C196972BF0754973E48C9C941092D86818CD94005E9A759B70BF6E48E6, these properties have some change tracking properties for efficiency. This doesn't make for a pleasant type, so we'll ignore this derived object and use the parent object instead.

Will detect types with "System.Data.Entity.DynamicProxies" then use the parent.

Add Support for Enums

For Xml and JSON this may involve getting the int value of the Enum.

For C#: This will involve setting the Enum value, which will require testing the property to determine if it is an Enum. This information can not be retrieved or deduced from the Expression, hence it will have to be determined from the Type.

Testing for enums may result in performance degradation.

Add setting to disable depth solver

this would be on the settings page and would be a parent to the max time and max depth options, if this is deselected they would both need to be grayed out.

Add support for C# 6.0 Initializers

This will need to be an option in the settings page to enable/disable. It's probably a good idea to enable it in VS 2015 by default and disable (by default) in earlier versions.

C# 6.0 Dictionary Initializer:

Dictionary<string, Customer> cList = new Dictionary<string, Customer>()
{
  ["A123"] = new Customer("A123"),
  ["B246"] = new Customer("B246")
};

Pre 6.0:

Dictionary<string, Customer> cList = new Dictionary<string, Customer>()
{
  {"A123", new Customer("A123")},
  {"B246", new Customer("B246")}
};

Not handling nullable DataTime correctly

DateTime looks good:

public class ObjectWithDate
{
    public DateTime ADateTime { get; set; }
}


        var objectWithDate = new ObjectWithDate
        {
            ADateTime = new DateTime(2015, 5, 29, 11, 45, 0),
        };

The export yields this (except the month issue, it looks good):
var objectWithDate = new MyNameSpace.ObjectWithDate
{
ADateTime = new DateTime(2015, 5, 5, 29, 11, 45, 0)
};

However if I change the type to nullable like so:

public class ObjectWithDate
{
    public DateTime? ADateTime { get; set; }
}

I get this:

var objectWithDate = new MyNameSpace.ObjectWithDate
{
new System.DateTime?
{
Date = new DateTime(2015, 5, 5, 29, 0, 0, 0),
Day = 29,
DayOfWeek = Friday,
DayOfYear = 149,
Hour = 11,
Kind = Unspecified,
Millisecond = 0,
Minute = 45,
Month = 5,
Second = 0,
Ticks = 635684967000000000,
TimeOfDay = new TimeSpan(0, 11, 45, 0, 0),
Year = 2015
}
};

Otherwise this is a great tool, keep up the good work.
Cheers,
Rob

Visual Studio 2015 - List Traversal broken

Object Exporter in VS2015 seems to be broken when it hits generic lists. It will not traverse down them. I tested the same code in 2013 and it worked perfectly. Here's my test case

namespace TestObjectExporter
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var test = new Data1
            {
                Name = "Data1",
                DataTwos = new List<Data2>
                {
                    new Data2
                    {
                        Name = "Data2",
                        DataThrees = new List<Data3>
                        {
                            new Data3
                            {
                                Name = "Data3"
                            },
                            new Data3
                            {
                                Name = "Data3"
                            },
                            new Data3
                            {
                                Name = "Data3"
                            }
                        }
                    },
                    new Data2
                    {
                        Name = "Data2",
                        DataThrees = new List<Data3>
                        {
                            new Data3
                            {
                                Name = "Data3"
                            },
                            new Data3
                            {
                                Name = "Data3"
                            },
                            new Data3
                            {
                                Name = "Data3"
                            }
                        }
                    },
                    new Data2
                    {
                        Name = "Data2",
                        DataThrees = new List<Data3>
                        {
                            new Data3
                            {
                                Name = "Data3"
                            },
                            new Data3
                            {
                                Name = "Data3"
                            },
                            new Data3
                            {
                                Name = "Data3"
                            }
                        }
                    }
                }
            };

            var count = test.DataTwos.Count;
            //breakpoint here
        }
    }

    public class Data1
    {
        public string Name { get; set; }
        public List<Data2> DataTwos { get; set; }
    }

    public class Data2
    {
        public string Name { get; set; }
        public List<Data3> DataThrees { get; set; }
    }

    public class Data3
    {
        public string Name { get; set; }
    }
}

When I do an export with Max Object Depth = 7
Exclude private properties and fields = Checked

var test = new TestObjectExporter.Data1
{
    DataTwos = new System.Collections.Generic.List<TestObjectExporter.Data2>
    {
        Capacity = 4,
        Count = 3,
        System.Collections.Generic.ICollection<TestObjectExporter.Data2>.IsReadOnly = false,
        System.Collections.ICollection.IsSynchronized = false,
        System.Collections.ICollection.SyncRoot = {object},
        System.Collections.IList.IsFixedSize = false,
        System.Collections.IList.IsReadOnly = false,
        _items = new TestObjectExporter.Data2[]
        {
        },
        _size = 3,
        _syncRoot = {object},
        _version = 3
    },
    Name = "Data1"
};

Resolve Recursions with Multiple Exported Objects in C# Generator

At the moment recursive objects are exported as is to a depth. In the C# generator we may be able to resolve recursive object references by generating these objects. This would require a change to the depth solver (and would probably require a C# depth solver and a JSON/XML depth solver).

We likely would not be able to do the same for XML/JSON since we output object values but can't link to another XML or JSON object.

Please consider adding explicit license to ObjectExporter

Would you consider adding a license file to this project? This would be consistent with good community practices and would allow others to build upon your work with a clear set of rules for what is acceptable.

For maximum compatibility with other free software projects, please consider using MIT license, such as expressed here:

https://github.com/intel352/vagrant-shell-scripts/blob/master/LICENSE.md

(replace the copyright statement with your copyright, of course)

Add JSON and XML support for Dictionaries

currently outputs:

    "Dict": 
    [
        [
            "Key": "a",
            "Value": "apple"
        ], 
        [
            "Key": "b",
            "Value": "bear"
        ], 
        [
            "Key": "c",
            "Value": "couch"
        ] 
    ], 

should output:

   "Dict": 
   {  
      "a":"apple",
      "b":"bear",
      "c":"couch"
   },

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.