Generate test data from a REGEX - c#

Folks,
Does anyone know of a dll or .net code that will generate test data from a REGEX?
I am aware of The Regular Expression Generator and the solutions offered in the stackoverflow question Using Regex to generate Strings rather than match them.
Unfortunately, I am writing in C#, and I need to generate the test data at run time.
I have also tried Rex, but it blows an error when I try to load it on a virtual machine.
Any help would be appreciated.
Regards,
Brett Nieland

There is a Microsoft reasearch tool called Rex that explores .NET regexes and generates members efficiently. http://research.microsoft.com/en-us/projects/rex/
As I have seen, you already tried Rex: Maybe the blog post from Chris Eargle helps you then.

You may also want to look at project Fare. See the answer at this question: convert nfa to dfa

Related

Self-contained Hello World type example for NHibernate

I've been fussing around with NHibernate tutorials for months (yeah...literaly) with no success. I wanted to just get a basic "hello world" level example down pat so I could work with it and massage it into a proper use case but I can never get past the deprecated code or missing library files.
I can only assume that it is me who is at fault because of NHibernate's popularity. Would someone pleeeeeeasee lead me to a self-contained example that I can just download and run? I would absolutely appreciate it.
Many thanks to everyone (with the exception of Diego) for their help. Special thanks to Michael Buen for his suggestion with using Fluent NHibernate.
There is a great example of NHibernate 3.0 in action here that I got to work: http://www.d80.co.uk/post/2011/02/20/Linq-to-NHibernate-Tutorial.aspx
Now all I need to do is learn exactly what's going on and mold it to my uses.

All C# Syntax in a single cs file

I heard about there being a cs file on the internet from a couple different sources that has all of the syntax in C# in a single file, which would be really good for a crash course to get ready for a job I have. Unfortunately no one could point me to the exact file, has anyone heard or seen anything like this?
Is this the one you're looking for?
http://blogs.msdn.com/b/kirillosenkov/archive/2010/05/11/updated-c-all-in-one-file.aspx
I've found this one useful:
http://www.harding.edu/fmccown/vbnet_csharp_comparison.html
There is updated AllInOne.cs document in official ANTLR grammars repository (with C# 5 & 6 support). Also you can find document with AllInOne in Roslyn.

How to convert vb.net coded to WORKING c# code?

Hi I want to convert the code at Webcam using DirectShow.NET to C#. It works perfectly in vb.net. I tried converting using an online converter, however I got about 30 errors,
Any suggestions to what I must do next:
This is the converter that I used :
1) Convert VB.NET to C#
The CodeProject article says the author originally converted this sample from C# to VB.NET. This may be the original C# source:
Link
Who says you even have to convert it? You could throw it in a Class Library and use the DLL in your C# project. No need for translating perfectly working .Net code into other .Net code.
Without the errors and relavent source code, we can't really help. The best bet is to use an online converter (as you did) and fix compiler errors, then test for other errors.
I've used sharpdevelop to translate between vb and c# a few times for projects. It's really pretty great, only had to make minor changes.
http://www.sharpdevelop.net
Use RedGate's reflector against the compiled assembly and the Denis Bauer's disassembler to get back code in the language of your choice.
I'd echo the npinti's suggestion; but I've never found a converter that will do everything flawlessly.
My guess is that you'll find several that do a good/great job; but you're still going to have to do a little work to get everything to play nice.
Learn C#, then convert it.
Maybe C-Sharpener For VB will work
Here is your golden ticket!!! ;) When i found this tool (which does a perfect conversion 99% of the time, it really make s a VB developers life easier and opens up all the online snippets and samples exclusively in C now available for a VB'er... Which BTW- is so overlooked on it's strengths at this point, it's just, well, crazy! ;)
Here is that 'gem' i am referring to: http://converter.telerik.com/
Hope that helps!!!

Lex/Yacc for C#?

Actually, maybe not full-blown Lex/Yacc. I'm implementing a command-interpreter front-end to administer a webapp. I'm looking for something that'll take a grammar definition and turn it into a parser that directly invokes methods on my object. Similar to how ASP.NET MVC can figure out which controller method to invoke, and how to pony up the arguments.
So, if the user types "create foo" at my command-prompt, it should transparently call a method:
private void Create(string id) { /* ... */ }
Oh, and if it could generate help text from (e.g.) attributes on those controller methods, that'd be awesome, too.
I've done a couple of small projects with GPLEX/GPPG, which are pretty straightforward reimplementations of LEX/YACC in C#. I've not used any of the other tools above, so I can't really compare them, but these worked fine.
GPPG can be found here and GPLEX here.
That being said, I agree, a full LEX/YACC solution probably is overkill for your problem. I would suggest generating a set of bindings using IronPython: it interfaces easily with .NET code, non-programmers seem to find the basic syntax fairly usable, and it gives you a lot of flexibility/power if you choose to use it.
I'm not sure Lex/Yacc will be of any help. You'll just need a basic tokenizer and an interpreter which are faster to write by hand. If you're still into parsing route see Irony.
As a sidenote: have you considered PowerShell and its commandlets?
Also look at Antlr, which has C# support.
Still early CTP so can't be used in production apps but you may be interested in Oslo/MGrammar:
http://msdn.microsoft.com/en-us/oslo/
Jison is getting a lot of traction recently. It is a Bison port to javascript. Because of it's extremely simple nature, I've ported the jison parsing/lexing template to php, and now to C#. It is still very new, but if you get a chance, take a look at it here: https://github.com/robertleeplummerjr/jison/tree/master/ports/csharp/Jison
If you don't fear alpha software and want an alternative to Lex / Yacc for creating your own languages, you might look into Oslo. I would recommend you to sit through session recordings of sessions TL27 and TL31 from last years PDC. TL31 directly addresses the creation of Domain Specific Languages using Oslo.
Coco/R is a compiler generator with a .NET implementation. You could try that out, but I'm not sure if getting such a library to work would be faster than writing your own tokenizer.
http://www.ssw.uni-linz.ac.at/Research/Projects/Coco/
I would suggest csflex - C# port of flex - most famous unix scanner generator.
I believe that lex/yacc are in one of the SDKs already (i.e. RTM). Either Windows or .NET Framework SDK.
Gardens Point Parser Generator here provides Yacc/Bison functionality for C#. It can be donwloaded here. A usefull example using GPPG is provided here
As Anton said, PowerShell is probably the way to go. If you do want a lex/ yacc implementation then Malcolm Crowe has a good set.
Edit: Direct Link to the Compiler Tools
Just for the record, implementation of lexer and LALR parser in C# for C#:
http://code.google.com/p/naive-language-tools/
It should be similar in use to Lex/Yacc, however those tools (NLT) are not generators! Thus, forget about speed.

Is there an Application to Create Regular Expression Out of Text by Selecting Wanted Area?

I hope this is programmer-related question. I'm in the hobby business of C# programming. For my own purposes I need to parse html files and the best idea is..regular expression. As many found out, it's quite time consuming to learn them and thus I'm quite interested if you know about some application that would be able to take input (piece of any code), understand what i need (by Me selecting a piece of the code I need to "cut out"), and give me the proper regular expression for it or more options.
As I've heard, Regex is a little science of itself, so it might not be as easy as I'd imagine.
Yes there is Roy Osherove wrote exactly what you're looking for - regulazy
Not real answer to your question, as it has nothing to do with regex, but HtmlAgilityPack may help you with your parsing.
You might also want to try txt2re : http://txt2re.com/, which tries to identify patterns in a user-supplied string and allows to build a regex out of them.
I gotta agree with Sunny on this one: if you're parsing html, you're better off converting it to XML (using the HTML Agility pack it's trivially easy) and then you can using XPATH expressions rather than regular expressions, it's far better suited to the job.

Categories

Resources