[C#] Class Tools

Started by Blizzard, February 10, 2011, 05:08:08 pm

Previous topic - Next topic

Blizzard

February 10, 2011, 05:08:08 pm Last Edit: July 28, 2015, 05:25:26 pm by Blizzard
Class Tools
Authors: Blizzard
Version: 0.94
Type: Programming Tools



Introduction

Are you sick of having to write code for classes from the beginning? Are you using languages like C++ that have no reflection and serialization becomes a bothersome process to implement? Are you sick of having to manually create all the instances of a class be it by reading a binary file or XML? Your problems will not be solved automatically, but here is something that will make all of these tasks so much easier: Class Tools!

This set of tools was created in C# and supports plugins that can be coded in C# as well.

Class Tools was primarily intended for use on other development platforms and for other programming languages than C#. In other words, you are using a tool created in C# to generate code and data for a project that is being made in another language such as C++, Python, Ruby, Basic, etc.

Class Tools at github + Official Plugins

This work is protected by the following license:
Spoiler: ShowHide
Quote
Copyright (c) Boris Mikic
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.



Features

Currently Class Tools consists out of the following applications.

Class Maker Features:

  • Allows you to create class models with definitions of variables and methods.

  • Save and load models that you create at any time.

  • Generate any kind of code for your model with the plugin supported code generator system.

  • Create your own generator plugins with maximum simplicity.



Data Maker Features:

  • Create instances of classes from a model that you have created in Class Maker.

  • Save and load the databases that you create at any time.

  • Update the model of your database with an version of the model altered Class Maker after you have created the database.

  • Save and load databases that you create at any time.

  • Create your own exporters to export your databases into well-known formats such as XML, binary, etc. or formats that you have created yourself.




Download

Class Maker v0.94
Downloads:
Class Maker v0.94
Plugins:
C++ Source Code Generator v0.93
C++ Binary Serialization Code Generator v1.0
C++ Lite Serializer Code Generator v1.0

Class Maker v0.93
Downloads:
Class Maker v0.93
Plugins:
C++ Source Code Generator v0.93
C++ Binary Serialization Code Generator v1.0
C++ Lite Serializer Code Generator v1.0

Class Maker v0.92
Downloads:
Class Maker v0.92
Plugins:
C++ Source Code Generator v0.92
C++ Binary Serialization Code Generator v1.0
C++ Lite Serializer Code Generator v1.0

Class Maker v0.91
Downloads:
Class Maker v0.91
Plugins:
C++ Source Code Generator v0.91
C++ Binary Serialization Code Generator v1.0
C++ Lite Serializer Code Generator v1.0

Class Maker v0.9
Downloads:
Class Maker v0.9
Plugins:
C++ Source Code Generator v0.9
C++ Binary Serialization Code Generator v0.9
C++ Lite Serializer Code Generator v0.9

Data Maker v0.94
Downloads:
Data Maker v0.94
Plugins:
C++ Lite Serializer Database Dumper v1.0

Data Maker v0.93
Downloads:
Data Maker v0.93
Plugins:
C++ Lite Serializer Database Dumper v1.0

Data Maker v0.92
Downloads:
Data Maker v0.92
Plugins:
C++ Lite Serializer Database Dumper v1.0

Data Maker v0.91
Downloads:
Data Maker v0.91
Plugins:
C++ Lite Serializer Database Dumper v1.0

Data Maker v0.9
Downloads:
Data Maker v0.9
Plugins:
C++ Lite Serializer Database Dumper v0.8



Installing Plugins

In order to install a plugin into one of the tools in Class Tools, simply create a folder called "Plugins" in the same folder as the tools executable and copy the DLLs into that folder. The tool will automatically detect the new generator plugins and allow you to use them.



Creating Plugins

If you want to create a plugin yourself:


  • Create a new C# project as a Class Library.

  • Right click on "References" and select "Add References".

  • Choose the "Browse" tab and find the files ClassTools.IPlugin.dll and ClassTools.Data.dll. Those files are included in every tool of Class Tools.

  • Make sure your project uses .NET 3.5. Class Tools can't load projects from higher framework versions and your project won't be able to load ClassTools.Plugin.IPlugin if it is less than 3.5 so your project has to use .NET 3.5.

  • Implement your own plugin by inheriting the ClassTools.Plugin.IPlugin interface.

  • Compile and you are ready to go!

  • Use the provided ClassTools.Data classes to create your own plugin that generates source or binary files based on the meta data that one of the Class Tools sends to your plugin.



The ClassTools.Plugin.IPlugin interface defines several properties and methods which you have to implement in your own generator plugin:

Properties:

  • Name: the name of your generator plugin

  • Description: a brief description of what your generator plugin does

  • Author: your name or pseudonym

  • Version: the version of the generator plugin

  • ToolId: the tool ID for which the plugin was intended



Methods:

  • void Create(): This method is called when your generator plugin is created.

  • void Destroy(): This method is called when your generator plugin is destroyed.

  • string Execute(ClassTools.Data.Base data, string path): Implement here your generator logic. The parameter "data" is the object that you will get depending on which tool is used. The parameter "path" is the folder path where you should create the generated files. The return value is a string that will be displayed to the user. Use it to notify the user of possible errors or complications with your generator plugin.



Tool Specific Stuff

Class Maker:

  • Tool ID: ClassMaker

  • Execute method "data" parameter: instance of ClassTools.Data.Hierarchy.Model



Data Maker:

  • Tool ID: DataMaker

  • Execute method "data" parameter: instance of ClassTools.Data.Database.Repository





Compatibility

All tools of Class Tools require Microsoft .NET Framework 3.5 to be installed (comes by default default with Windows XP Service Pack 3 and Windows 7).



Author's Notes

Keep in mind that Class Tools is still a project in development. Currently both Class Maker and Data Maker are available, but both programs are still missing some features.
.NET 3.5 has been selected for usage because it comes by default with Windows XP Service Pack 3 and Windows 7 while it provides a big deal of the .NET functionality and classes for your plugin.
You are not limited to plugin development only. You can also create a full fledged application yourself.

If you find any bugs, please report them here:
http://forum.chaos-project.com
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

winkio

I can see where this would be useful if you were planning ahead and hard a large set of similar classes that you needed to make at once.  I, being a hobbyist programmer, just do everything on the fly, and don't really have a system of organization that would let me take advantage of this.  Still, nice job with the program, and the plugin system :D

Blizzard

The primary reason I made this was for the automated serialization code generator. xD
But I realized all the additional applications which is why I want to finish the Class Maker and make the Data Maker.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

Finally got around to creating a Ruby Source Generator plugin. For the most part, this plugins pretty functional and I think I implemented just about everything needed to create classes on the fly. This is the output of a test class I created.
Spoiler: ShowHide
class Enemy

  attr_reader :hp
  attr_reader :max_hp
  attr_accessor :name
  attr_accessor :invincible

  def kill
    @hp = 0
  end

  def initialize(enemy_graphic)
    @hp = 100
    @max_hp = 100
    @name = "Ghost"
    @invincible = false
    @skills = nil
    print "test"
  end

  def hp=(n)
    @hp = [[0, n].max, @max_hp].min
  end

  def hp_percent
    return 0.0 if @max_hp < 1
    return (@hp.to_f / @max_hp.to_f) * 100.0
  end

  def dead?
    return (@hp < 1)
  end

end


Capabilities:
  • Uses Getter and Setter functions to create accessors

  • Tries to parse ints, floats, and bools from Default Value

  • No default value? Set to nil

  • Automatically creates "initialize" method, if one hasn't been defined in the Methods box

  • Automatically implements all defined methods with implementations

  • Automatically indents everything

  • If module is defined, it'll plug the module right in front of the class



This plugin is made for Class Maker.
Ruby Class Generator (0.9)

Notes:

Initialize Method
The plugin will automatically generate the initialize method for you. However, if you want to define your own, you can simply add a method to your class, and name it initialize. The plugin will try and detect if you've defined one on your own. The reason I did this is in case you wanted to define parameters for your class. Example, you could set the name to "initialize(enemy_id)" and the plugin will detect that, and generate the initialize method with that, rather than the normal initialize.

Bools, Ints, Floats, and Others
The plugin will try to parse out ints, bools, and floats from the default values. If it fails to do so, it'll just plug the default value in as is. Eventually the plugin will take advantage of the Variable Types drop down box. As for any other possible value like strings or objects, the plugin will not do anything to them. It'll just plug them right in. So if you do plan on setting a string for a default value, don't forget the quotes! If you leave the default value blank, it'll set the variable as nil.

Attributes
The Getter and Setter checkboxes are what defines the attributes and the variable access level. Checking both the Getter and Setter produces an accessor attribute. Just Getter will produce a reader attribute, while Setter will just produce a writer attribute.

If you have any questions or would like the source code, let me know. :3

Blizzard

Nice work. :3
Nah, I don't think that the source code will be necessary. xD
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Blizzard

I moved the whole thing to github. Assembla sucks ass now.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

PhoenixFire

This is the first time I'm seeing this topic, but great work, and love the idea =) I may look into this more, as I'm going to be learning Cpp I think.
Quote from: Subsonic_Noise on July 01, 2011, 02:42:19 amNext off, how to create a first person shooter using microsoft excel.

Quote from: Zeriab on September 09, 2011, 02:58:58 pm<Remember when computers had turbo buttons?

Blizzard

I wrote this in C#, not C++. xD
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

PhoenixFire

I thought I read that it can be used to help write in other languages (I know it's written in c# hahaha... it's right in the title :p  )
Quote from: Subsonic_Noise on July 01, 2011, 02:42:19 amNext off, how to create a first person shooter using microsoft excel.

Quote from: Zeriab on September 09, 2011, 02:58:58 pm<Remember when computers had turbo buttons?

Ryex

it can prototype classes in other languages, provided there is a plugin to do so.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

PhoenixFire

Quote from: Ryex on August 05, 2015, 11:15:33 pm
it can prototype classes in other languages, provided there is a plugin to do so.


Ah, okay, gotcha. Either way it's still really cool as a tool.
Quote from: Subsonic_Noise on July 01, 2011, 02:42:19 amNext off, how to create a first person shooter using microsoft excel.

Quote from: Zeriab on September 09, 2011, 02:58:58 pm<Remember when computers had turbo buttons?