Bug 4144 - Monodevelop sets default namespace (rootnamespace) if empy
Summary: Monodevelop sets default namespace (rootnamespace) if empy
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: General ()
Version: Trunk
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-03-29 04:06 UTC by radekp
Modified: 2012-04-04 14:45 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Sample project (15.13 KB, application/x-compressed-tar)
2012-03-29 04:06 UTC, radekp
Details
Proposed fix (1.19 KB, patch)
2012-03-29 04:24 UTC, radekp
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description radekp 2012-03-29 04:06:07 UTC
Hi,
i am using empty default namespace (RootNamespace in the build file) for my projects.

This works with Visual Studio 2003/2008, but Monodevelop for some reason always change the empty default namespace to project name.

This affects embedded resource paths and the programs do not work. Attached is sample application:

open it in VS2008, rebuild, run -> you will see text written to console
open in in Monodeveop, rebuild, run -> you get null reference exception

the null reference is because default namespace was changed by monodevelop and embedded resource paths are different.
Comment 1 radekp 2012-03-29 04:06:41 UTC
Created attachment 1598 [details]
Sample project
Comment 2 radekp 2012-03-29 04:24:15 UTC
Created attachment 1599 [details]
Proposed fix
Comment 3 Mikayla Hutchinson [MSFT] 2012-03-29 16:52:37 UTC
I don't think it's that simple, I did a quick audit of MD that use the value, and looks like most places handle null/empty values, but the web services addin doesn't
Comment 4 Mikayla Hutchinson [MSFT] 2012-03-29 18:34:01 UTC
Fixed in master, thanks.
Comment 5 Alan McGovern 2012-04-04 13:29:24 UTC
This fix (commit 9fb07d423) results in the default namespace not being set for new projects which means the <RootNamespace> element is not in the csproj file. As a result, Mono for Android projects cannot compile properly as they rely on this value existing.
Comment 6 Mikayla Hutchinson [MSFT] 2012-04-04 13:42:15 UTC
Then we need to special-case M4A projects until they fix the targets.
Comment 7 Mikayla Hutchinson [MSFT] 2012-04-04 14:04:30 UTC
MD was definitely wrong in two regards
a) always setting DefaultNamespace when deserializing if it was empty
b) assuming that DefaultNamespace always had a value
Most of MD explicitly handled empty DefaultNamespace, so we did it correctly at some point.

I don't think it really matters whether we set it on *new* projects or not, especially considering that in VS, it could vary between project templates. You can do this by reverting the -149,9 +149,9 hunk from DotNetProject.cs in 9fb07d423f.

The M4A targets need to be fixed too, since people can clear the DefaultNamespace.
Comment 8 Alan McGovern 2012-04-04 14:45:49 UTC
I'll file a separate bug for the targets file. I reverted that segment of the commit and tested. It seems to be working great. Thanks!