RE: [nant-dev] RE: [Nant-users] Adding Tasks 0.7.9 vs 0.8

2003-02-14 Thread Brian Deacon
Granted, we're getting off topic... but Bill's Kung-Fu is clearly
stronger than mine and I wish to lean.  (And figure it might be
instructive to others)

So Bill,
Am I understanding correctly that this defeats the security of scoping
something as private?  Are there limits to this?  (Like does this work
across assemblies?)

(Yah, I know I could see for myself, but I'm late for work.)

:)

Brian

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] On Behalf Of Bill
Conroy
Sent: Wednesday, February 12, 2003 8:15 PM
To: 'Brian Deacon'; [EMAIL PROTECTED]; 'NAnt Developers
(E-mail)'
Subject: [nant-dev] RE: [Nant-users] Adding Tasks 0.7.9 vs 0.8

[Hello...new to the list]

 NAnt uses reflection in combination with the TaskAttribute 
 to match your attributes up with your properties and a privately 
 scoped property not only won't show up in reflection, 
 but NAnt wouldn't be able to assign to it even if it did.

You can view and set private members of a type. I have an example
below[1] that shows setting a private field on a type as well as a
private property.

The reason this doesn't work with Nant is because the Nant code
specifically checks only Public properties. Line 130 of Element.cs:

  PropertyInfo[] propertyInfoArray =
currentType.GetProperties(BindingFlags.Public|BindingFlags.Instance);

could be:

  PropertyInfo[] propertyInfoArray =
currentType.GetProperties(BindingFlags.NonPublic|BindingFlags.Instance);
Or:
  PropertyInfo[] propertyInfoArray =
currentType.GetProperties(BindingFlags.NonPublic|BindingFlags.Public|Bin
dingFlags.Instance);

HTH
-bc

[1]
code
namespace ReflectTest {
  using System;
  using System.Reflection;

  class Class1 {
static void Main(string[] args) {
  Class2 c2 = new Class2();
  Type t = typeof(Class2); // or c2.GetType()
  PropertyInfo[] propertyInfoArray =
t.GetProperties(BindingFlags.NonPublic|BindingFlags.Instance);
  foreach (PropertyInfo pi in propertyInfoArray ) {
System.Diagnostics.Debug.WriteLine(pi.Name);
pi.SetValue(c2, TestingProp, null);
  }
  // comments states I could do this, but code doesn't
  FieldInfo[] fis =
t.GetFields(BindingFlags.NonPublic|BindingFlags.Instance);
  foreach (FieldInfo fi in fis ) {
System.Diagnostics.Debug.WriteLine(fi.Name);
fi.SetValue(c2, TestingField);
System.Diagnostics.Debug.WriteLine(fi.GetValue(c2));
  }
}
  }

  class Class2 {
private string _prop;

private string prop {
  get {
return String.Empty;
  }

  set {
// for show
System.Diagnostics.Debug.WriteLine(value);
  }
}
  }
}
/code

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] On Behalf Of Brian
Deacon
Sent: Wednesday, February 12, 2003 9:39 PM
To: [EMAIL PROTECTED]; 'NAnt Developers (E-mail)'
Subject: RE: [Nant-users] Adding Tasks 0.7.9 vs 0.8


That will -definitely- keep it from working.  NAnt uses reflection in
combination with the TaskAttribute to match your attributes up with your
properties and a privately scoped property not only won't show up in
reflection, but NAnt wouldn't be able to assign to it even if it did.

Hmmm... Is there a flag to AttributeUsage that can specify public
properties only?  'twould seem nice if the compiler could have caught
that and failed the compile.

Brian
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] On Behalf Of Simon
Steele
Sent: Tuesday, February 11, 2003 7:14 AM
To: 'Gill, Bobby'; [EMAIL PROTECTED]
Subject: RE: [Nant-users] Adding Tasks 0.7.9 vs 0.8

Hi Bobby,

I wonder if you should have:

public string slnFileName
^^ Public access.

I'm not sure - without looking at your source, I couldn't be sure. All
of my attributes are marked as public, and I've never had this problem.

Simon.

 -Original Message-
 From: Gill, Bobby [mailto:[EMAIL PROTECTED]]
 Sent: 11 February 2003 14:59
 To: Simon Steele; [EMAIL PROTECTED]
 Subject: RE: [Nant-users] Adding Tasks 0.7.9 vs 0.8
 
 Another problem that I am having is with setting the values
 of the TaskAttributes. For instance if I have:
 
 [TaskAttribute(solution,Required = true)]
   private string slnFileName 
   {
   get { return  slnFileName_m; } set {
 slnFileName_m=value;}
   }
 
 Whenever I try to reference the slnFileName_m variable, I
 receive Null pointer errors. My .build file does have the 
 solution attribute along with a value within, but for some 
 reason, it doesn't seem to be transferring over to the 
 variable within the solution property? Any ideas as to what I 
 am missing?? Thanks
 
 Bobby Gill
 [EMAIL PROTECTED]

__
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service.


---
This SF.NET email

[nant-dev] RE: [Nant-users] Adding Tasks 0.7.9 vs 0.8

2003-02-12 Thread Brian Deacon
That will -definitely- keep it from working.  NAnt uses reflection in
combination with the TaskAttribute to match your attributes up with your
properties and a privately scoped property not only won't show up in
reflection, but NAnt wouldn't be able to assign to it even if it did.

Hmmm... Is there a flag to AttributeUsage that can specify public
properties only?  'twould seem nice if the compiler could have caught
that and failed the compile.

Brian
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] On Behalf Of Simon
Steele
Sent: Tuesday, February 11, 2003 7:14 AM
To: 'Gill, Bobby'; [EMAIL PROTECTED]
Subject: RE: [Nant-users] Adding Tasks 0.7.9 vs 0.8

Hi Bobby,

I wonder if you should have:

public string slnFileName
^^ Public access.

I'm not sure - without looking at your source, I couldn't be sure. All
of my
attributes are marked as public, and I've never had this problem.

Simon.

 -Original Message-
 From: Gill, Bobby [mailto:[EMAIL PROTECTED]] 
 Sent: 11 February 2003 14:59
 To: Simon Steele; [EMAIL PROTECTED]
 Subject: RE: [Nant-users] Adding Tasks 0.7.9 vs 0.8
 
 Another problem that I am having is with setting the values 
 of the TaskAttributes. For instance if I have:
 
 [TaskAttribute(solution,Required = true)]
   private string slnFileName 
   {
   get { return  slnFileName_m; } set {
 slnFileName_m=value;}
   }
 
 Whenever I try to reference the slnFileName_m variable, I 
 receive Null pointer errors. My .build file does have the 
 solution attribute along with a value within, but for some 
 reason, it doesn't seem to be transferring over to the 
 variable within the solution property? Any ideas as to what I 
 am missing?? Thanks
 
 Bobby Gill
 [EMAIL PROTECTED]

__
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service.


---
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
___
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users



---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers



[nant-dev] RE: [Nant-users] Adding Tasks 0.7.9 vs 0.8

2003-02-12 Thread Bill Conroy
[Hello...new to the list]

 NAnt uses reflection in combination with the TaskAttribute 
 to match your attributes up with your properties and a privately 
 scoped property not only won't show up in reflection, 
 but NAnt wouldn't be able to assign to it even if it did.

You can view and set private members of a type. I have an example
below[1] that shows setting a private field on a type as well as a
private property.

The reason this doesn't work with Nant is because the Nant code
specifically checks only Public properties. Line 130 of Element.cs:

  PropertyInfo[] propertyInfoArray =
currentType.GetProperties(BindingFlags.Public|BindingFlags.Instance);

could be:

  PropertyInfo[] propertyInfoArray =
currentType.GetProperties(BindingFlags.NonPublic|BindingFlags.Instance);
Or:
  PropertyInfo[] propertyInfoArray =
currentType.GetProperties(BindingFlags.NonPublic|BindingFlags.Public|Bin
dingFlags.Instance);

HTH
-bc

[1]
code
namespace ReflectTest {
  using System;
  using System.Reflection;

  class Class1 {
static void Main(string[] args) {
  Class2 c2 = new Class2();
  Type t = typeof(Class2); // or c2.GetType()
  PropertyInfo[] propertyInfoArray =
t.GetProperties(BindingFlags.NonPublic|BindingFlags.Instance);
  foreach (PropertyInfo pi in propertyInfoArray ) {
System.Diagnostics.Debug.WriteLine(pi.Name);
pi.SetValue(c2, TestingProp, null);
  }
  // comments states I could do this, but code doesn't
  FieldInfo[] fis =
t.GetFields(BindingFlags.NonPublic|BindingFlags.Instance);
  foreach (FieldInfo fi in fis ) {
System.Diagnostics.Debug.WriteLine(fi.Name);
fi.SetValue(c2, TestingField);
System.Diagnostics.Debug.WriteLine(fi.GetValue(c2));
  }
}
  }

  class Class2 {
private string _prop;

private string prop {
  get {
return String.Empty;
  }

  set {
// for show
System.Diagnostics.Debug.WriteLine(value);
  }
}
  }
}
/code

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] On Behalf Of Brian
Deacon
Sent: Wednesday, February 12, 2003 9:39 PM
To: [EMAIL PROTECTED]; 'NAnt Developers (E-mail)'
Subject: RE: [Nant-users] Adding Tasks 0.7.9 vs 0.8


That will -definitely- keep it from working.  NAnt uses reflection in
combination with the TaskAttribute to match your attributes up with your
properties and a privately scoped property not only won't show up in
reflection, but NAnt wouldn't be able to assign to it even if it did.

Hmmm... Is there a flag to AttributeUsage that can specify public
properties only?  'twould seem nice if the compiler could have caught
that and failed the compile.

Brian
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] On Behalf Of Simon
Steele
Sent: Tuesday, February 11, 2003 7:14 AM
To: 'Gill, Bobby'; [EMAIL PROTECTED]
Subject: RE: [Nant-users] Adding Tasks 0.7.9 vs 0.8

Hi Bobby,

I wonder if you should have:

public string slnFileName
^^ Public access.

I'm not sure - without looking at your source, I couldn't be sure. All
of my attributes are marked as public, and I've never had this problem.

Simon.

 -Original Message-
 From: Gill, Bobby [mailto:[EMAIL PROTECTED]]
 Sent: 11 February 2003 14:59
 To: Simon Steele; [EMAIL PROTECTED]
 Subject: RE: [Nant-users] Adding Tasks 0.7.9 vs 0.8
 
 Another problem that I am having is with setting the values
 of the TaskAttributes. For instance if I have:
 
 [TaskAttribute(solution,Required = true)]
   private string slnFileName 
   {
   get { return  slnFileName_m; } set {
 slnFileName_m=value;}
   }
 
 Whenever I try to reference the slnFileName_m variable, I
 receive Null pointer errors. My .build file does have the 
 solution attribute along with a value within, but for some 
 reason, it doesn't seem to be transferring over to the 
 variable within the solution property? Any ideas as to what I 
 am missing?? Thanks
 
 Bobby Gill
 [EMAIL PROTECTED]

__
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service.


---
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
___
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users



---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf ___
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users



---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.