Bugs item #1558571, was opened at 2006-09-14 12:28
Message generated for change (Comment added) made by coolpero2
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=402868&aid=1558571&group_id=31650

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 7
Submitted By: coolpero2 (coolpero2)
Assigned to: Nobody/Anonymous (nobody)
Summary: Bad value in Application.CompanyName property

Initial Comment:

I'm running NANT 2.2.8 for .NET 1.1 
and have a test case that at some point reads property  
System.Windows.Forms.Application.UserAppDataPath.

Getter of this property creates a directory if it
doesn't exists and the name of the directory is derived
from
Base Path\CompanyName\ProductName\ProductVersion (look
at
http://msdn2.microsoft.com/en-us/library/system.windows.forms.application.userappdatapath.aspx
).

The thing is that when running nant from command line
value of Application.CompanyName =
http://nant.sourceforge.net
and : and / are not permitted for folder names.

Plase correct this in next release.

Otherwise compliments to all developers for excelent tool.

Greetings, Petar Repac


----------------------------------------------------------------------

>Comment By: coolpero2 (coolpero2)
Date: 2006-10-18 09:06

Message:
Logged In: YES 
user_id=1598059

You got some point there, I agree. 
If one want to use .NET framework
Application.UserAppDataPath there isn't much to do.
On the other side if we look at .NET framework as
OS-independant it would be incorrect to implement Windows
folder restrictions in that method.

Anyway, we implemented our custom way to create directory
for user data and will exclude/substitute any non-allowed
characters. 

So, as I'm concerned, you can close this issue if you decide
not to change CompanyName attribute.

Thank you for your time and comments.
Petar

----------------------------------------------------------------------

Comment By: Gary Feldman (garyfx)
Date: 2006-10-17 21:53

Message:
Logged In: YES 
user_id=847172

However, the documentation for the Company Name attribute is
at
http://msdn2.microsoft.com/en-us/library/system.reflection.assemblycompanyattribute.aspx,
which makes no mention of that.

In any event, since you can't impose any restrictions on the
the company name to users of your assembly, then you need to
be prepared to for the possibility that one of those users
will define it with characters that can't be used in a
folder name.  In other words, having your test fail is the
correct behavior, because the code isn't handling the case
where the user put a bad character into the company name. 
What happens if E*Trade wants to use it, and they insist on
having the asterisk in their name.  Probably the easiest
thing to do is to catch the failure and work around it.

It's also not clear to me why you might be using this.  Are
your users customers from a different company?  Then you
shouldn't be using the appdata directory that belongs to
that other company.  If they're within your company, then
again, hardwiring it is ok.

I don't mean to be obstinate.  It's just that the assembly
attributes are so deceptively simple that people (including,
apparently, Microsoft) don't take the time to deal with the
edge cases or anticipate other ways in which they're being used.

----------------------------------------------------------------------

Comment By: coolpero2 (coolpero2)
Date: 2006-10-17 16:42

Message:
Logged In: YES 
user_id=1598059

>...as far as I know there are no constraints on the
>CompanyName attribute prohibiting special characters.  

I don't agree. Look at
http://msdn2.microsoft.com/en-us/library/system.windows.forms.application.userappdatapath.aspx
It says: "If a path does not exist, one is created in the
following format: 
Base Path\CompanyName\ProductName\ProductVersion"

Now, that means that CompanyName must adhere to constraints
that are in place for folder names in the underlying OS.

Take a look at this example. It will compile, but fail in
run-time.
using System;
using System.Windows.Forms;
using System.Reflection;

[assembly: AssemblyCompany("http://nant.sourceforge.net";)]

class Program {

  [STAThread]
  static void Main(string[] args) {
    Console.WriteLine(Application.UserAppDataPath);
  }
}

Please, note that I'm building and testing a class that is
part of our library assembly and I can't impose any
restriction on CompanyName to users of this assembly.

So, currently, when *any code* that is run under NAnt (NUnit
tests, for example) calls Application.UserAppDataPath it
will fail.

I understand that it would be better that MS checks
CompanyName value in its setter in run-time, but then I
would wait for solution for years probably :))

Regards, 
Petar

----------------------------------------------------------------------

Comment By: Gary Feldman (garyfx)
Date: 2006-10-17 14:54

Message:
Logged In: YES 
user_id=847172

While I suppose there may be better choices for the company
name, as far as I know there are no constraints on the
CompanyName attribute prohibiting special characters.  The
problem comes in when you try to adhere to Microsoft's
guidelines about where to put application data, and use the
CompanyName attribute as the company name folder.

The reality is that you can't assume that the company name
will be a valid folder name.  If you're writing code that is
using the CompanyName attribute, where you don't control its
values, then you're forced to process the result to make it
a legal folder name.

But my guess is that you do control the attribute in the
final product, just not in the test system.  But such a test
case would break anyway, since you don't want the result to
be NAnt, you want it to be your own company name.

This is one example of a common testing problem, where the
test isn't running in the final environment.  There are a
number of ways around this, but they generally boil down to
having the test system control the environment.  One way
around this is to simply have a really simple CompanyName
class that can be mocked by the tests, and then rely upon
formal code review instead of tests to validate that
particular class.

The other alternative is to simply not use the CompanyName
attribute for this folder.  Presumably it's a name you
control, and thus you can hardwire it, possibly even in the
same source file as your own CompanyName attribute declaration.


----------------------------------------------------------------------

Comment By: coolpero2 (coolpero2)
Date: 2006-09-14 14:22

Message:
Logged In: YES 
user_id=1598059

I already corrected my mistake in comment below.
I'm running 
NAnt 0.85 (Build 0.85.2344.0; rc4; 02.06.2006).


----------------------------------------------------------------------

Comment By: coolpero2 (coolpero2)
Date: 2006-09-14 14:20

Message:
Logged In: YES 
user_id=1598059

I already corrected my mistake in comment below.
I'm running 
NAnt 0.85 (Build 0.85.2344.0; rc4; 02.06.2006).


----------------------------------------------------------------------

Comment By: Gary Feldman (garyfx)
Date: 2006-09-14 14:16

Message:
Logged In: YES 
user_id=847172

I don't see any 2.2.8 listed among the release packages, and
it certainly doesn't look like any NAnt version number
(which would begin with a 0).  

Please check the version number again.  You should be
running either 0.85-rc4 or a more recent nightly build.  Let
us know either way.


----------------------------------------------------------------------

Comment By: coolpero2 (coolpero2)
Date: 2006-09-14 13:28

Message:
Logged In: YES 
user_id=1598059

Sorry, I made a mistake.
The version of NAnt is 
NAnt 0.85 (Build 0.85.2344.0; rc4; 02.06.2006).

NUnit used was 2.2.8.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=402868&aid=1558571&group_id=31650

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
nant-developers mailing list
nant-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-developers

Reply via email to