Bug 312539 (MONO45833) - Cannot distinguish Class type and Value type
Summary: Cannot distinguish Class type and Value type
Status: RESOLVED FIXED
Alias: MONO45833
Product: Mono: Runtime
Classification: Mono
Component: misc (show other bugs)
Version: unspecified
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords: theme
Depends on:
Blocks:
 
Reported: 2003-07-04 08:25 UTC by He HongFu
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
This is the source file. (2.57 KB, text/plain)
2003-07-04 08:26 UTC, Thomas Wiest
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 18:12:27 UTC


---- Reported by hfhe@stryon.com 2003-07-04 01:25:27 MST ----

Please fill in this template when reporting a bug, unless you know what 
you are doing.
Description of Problem:
There two type to denote a C struct in CSharp, one is a class, another is 
a struct:
[ StructLayout( LayoutKind.Sequential )]   
public class OSVersionInfo 
{			
    public int OSVersionInfoSize;
    public int majorVersion; 
    public int minorVersion;
    public int buildNumber;
    public int platformId;

	[ MarshalAs( UnmanagedType.ByValTStr, SizeConst=128 )]    
    public String versionString;
}

[ StructLayout( LayoutKind.Sequential )]  
public struct OSVersionInfo2 
{
    public int OSVersionInfoSize;
    public int majorVersion; 
    public int minorVersion;
    public int buildNumber;
    public int platformId;

	[ MarshalAs( UnmanagedType.ByValTStr, SizeConst=128 )]    
    public String versionString;
}

when call system library function GetVersionEx, take this type parameter,
the ref struct can get correct result, but class failed.

Steps to reproduce the problem:
1. 
2. 
3. 

Actual Results:
Class size:    148
Major version: 0
Minor version: 0
Build number:  0
Platform ID:   0
Version:

Passing OSVersionInfo as struc
Struct size:   148
Major version: 5
Minor version: 0
Build number:  2195
Platform ID:   2
Version:       Service Pack 3

Expected Results:
Class size:    148
Major version: 5
Minor version: 0
Build number:  2195
Platform ID:   2
Version:       Service Pack 3

Passing OSVersionInfo as struct
Struct size:   148
Major version: 5
Minor version: 0
Build number:  2195
Platform ID:   2
Version:       Service Pack 3

How often does this happen? 
Each time

Additional Information:



---- Additional Comments From hfhe@stryon.com 2003-07-04 01:26:40 MST ----

Created an attachment (id=164777)
This is the source file.




---- Additional Comments From dietmar@ximian.com 2003-07-04 04:58:32 MST ----

Ok, the marshaling code does not consider the [out] attribute - will
try to fix that.



---- Additional Comments From dietmar@ximian.com 2003-07-04 05:50:03 MST ----

fixed 

Imported an attachment (id=164777)

Unknown bug field "cf_op_sys_details" encountered while moving bug
   <cf_op_sys_details>Windows 2000</cf_op_sys_details>
Unknown operating system unknown. Setting to default OS "Other".