Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled exception running the Code generator against a C# class with no namespace #4

Open
Numpsy opened this issue Jan 5, 2016 · 3 comments

Comments

@Numpsy
Copy link
Contributor

Numpsy commented Jan 5, 2016

I noticed this when trying to run the Dubrovnik.Generator.UI tool against a .NET library which exports a class that has no namespace defined.

The reflection part works ok, but then I get a NullReferenceException from http://www.github.com/ThesaurusSoftware/Dubrovnik/blob/master/dotNET/Dubrovnik.Tools/Dubrovnik.Tools/Net2ObjCPartial.cs#L1272 when doing the code gen step, as the 'managedIdentifier' parameter is a null string.

I'm not sure if the fix is just to return an empty string if managedIdentifier is null, or if it needs to handle that case differently.

@Thesaurus
Copy link
Contributor

I would start by using an empty string in the null case and proceed from there.
There are some other locations in the code gen that might squeal if the namespace is null/nil but I reckon it will be pretty obvious.
One location might well be where we generate a macro contraction of a fully qualified classname :

#define TWGShortened This_Will_Get_Shortened

On 5 Jan 2016, at 18:12, Richard Webb [email protected] wrote:

I noticed this when trying to run the DubrovnikGeneratorUI tool against a NET library which exports a class that has no namespace defined

The reflection part works ok, but then I get a NullReferenceException from http://wwwgithubcom/ThesaurusSoftware/Dubrovnik/blob/master/dotNET/DubrovnikTools/DubrovnikTools/Net2ObjCPartialcs#L1272 when doing the code gen step, as the 'managedIdentifier' parameter is a null string

I'm not sure if the fix is just to return an empty string if managedIdentifier is null, or if it needs to handle that case differently


Reply to this email directly or view it on GitHub #4.

@Numpsy
Copy link
Contributor Author

Numpsy commented Jan 6, 2016

The next place it falls over is in Net2ObjC.tt

https://github.com/ThesaurusSoftware/Dubrovnik/blob/master/dotNET/Dubrovnik.Tools/Dubrovnik.Tools/Net2ObjC.tt#L394

I tried changing CodeFacet.TypeNamespace to be an empty string instead of a null string if there is no namespace present, and that allowed the generation to succeed.

@Thesaurus Thesaurus reopened this Jan 6, 2016
@Thesaurus
Copy link
Contributor

You will have to account for the fact that the namespace is currently suffixed with a period. An empty namespace won't require that,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants