~wesleycutting/nunitlite/work

« back to all changes in this revision

Viewing changes to src/framework/Internal/RuntimeFramework.cs

  • Committer: Charlie Poole
  • Date: 2013-01-24 01:32:48 UTC
  • Revision ID: charlie@nunit.org-20130124013248-dh15al2hm5vcbpgl
Add CI Build target to build, using a console app to load the silverlight tests and run them

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
 
71
71
                private static RuntimeFramework currentFramework;
72
72
 
73
 
        private static Version[] knownVersions = new Version[] {
74
 
            new Version(1, 0, 3705),
75
 
            new Version(1, 1, 4322),
76
 
            new Version(2, 0, 50727),
77
 
            new Version(4, 0, 30319)
78
 
        };
79
 
 
80
73
        private RuntimeType runtime;
81
74
                private Version frameworkVersion;
82
75
                private Version clrVersion;
86
79
                #region Constructor
87
80
                
88
81
        /// <summary>
89
 
                /// Construct from a runtime type and version
 
82
                /// Construct from a runtime type and version. If the version has
 
83
        /// two parts, it is taken as a framework version. If it has three
 
84
        /// or more, it is taken as a CLR version. In either case, the other
 
85
        /// version is deduced based on the runtime type and provided version.
90
86
                /// </summary>
91
87
                /// <param name="runtime">The runtime type of the framework</param>
92
88
                /// <param name="version">The version of the framework</param>
94
90
                {
95
91
            this.runtime = runtime;
96
92
 
 
93
            this.frameworkVersion = runtime == RuntimeType.Mono && version.Major == 1
 
94
                ? new Version(1, 0)
 
95
                : new Version(version.Major, version.Minor);
 
96
            this.clrVersion = version;
 
97
 
97
98
            if (version.Build < 0)
98
 
                InitFromFrameworkVersion(version);
99
 
            else
100
 
                InitFromClrVersion(version);
 
99
                this.clrVersion = GetClrVersion(runtime, version);
101
100
 
102
 
            if (version.Major == 3)
103
 
                this.clrVersion = new Version(2, 0, 50727);
104
101
            this.displayName = GetDefaultDisplayName(runtime, version);
105
102
        }
106
103
 
107
 
        private void InitFromFrameworkVersion(Version version)
 
104
        private static Version GetClrVersion(RuntimeType runtime, Version version)
108
105
        {
109
 
            this.frameworkVersion = this.clrVersion = version;
110
 
            foreach (Version v in knownVersions)
111
 
                if (v.Major == version.Major && v.Minor == version.Minor)
112
 
                {
113
 
                    this.clrVersion = v;
114
 
                    break;
115
 
                }
116
 
 
117
 
            if (this.runtime == RuntimeType.Mono && version.Major == 1)
 
106
            switch (runtime)
118
107
            {
119
 
                this.frameworkVersion = new Version(1, 0);
120
 
                this.clrVersion = new Version(1, 1, 4322);
 
108
                case RuntimeType.Silverlight:
 
109
                    return version.Major >= 4
 
110
                        ? new Version(4, 0, 60310)
 
111
                        : new Version(2, 0, 50727);
 
112
 
 
113
                default:
 
114
                    switch (version.Major)
 
115
                    {
 
116
                        case 4:
 
117
                            return new Version(4, 0, 30319);
 
118
 
 
119
                        case 2:
 
120
                        case 3:
 
121
                            return new Version(2, 0, 50727);
 
122
 
 
123
                        case 1:
 
124
                            return version.Minor == 0 && runtime != RuntimeType.Mono
 
125
                                ? new Version(1, 0, 3705)
 
126
                                : new Version(1, 1, 4322);
 
127
 
 
128
                        default:
 
129
                            return version;
 
130
                    }
121
131
            }
122
132
        }
123
133
 
124
 
        private void InitFromClrVersion(Version version)
125
 
        {
126
 
            this.frameworkVersion = new Version(version.Major, version.Minor);
127
 
            this.clrVersion = version;
128
 
            if (runtime == RuntimeType.Mono && version.Major == 1)
129
 
                this.frameworkVersion = new Version(1, 0);
130
 
        }
131
 
                
132
134
                #endregion
133
135
 
134
136
        #region Properties
143
145
                if (currentFramework == null)
144
146
                {
145
147
#if SILVERLIGHT
146
 
                    RuntimeType runtime = RuntimeType.Silverlight;
147
 
                    int major = 4;
148
 
                    int minor = 0;
 
148
                    currentFramework = new RuntimeFramework(
 
149
                        RuntimeType.Silverlight, 
 
150
                        new Version(Environment.Version.Major, Environment.Version.Minor));
149
151
#else
150
152
                    Type monoRuntimeType = Type.GetType("Mono.Runtime", false);
151
153
                    Type monoTouchType = Type.GetType("MonoTouch.UIKit.UIApplicationDelegate, monotouch");
198
200
                            }
199
201
                        }
200
202
                    }
201
 
#endif
202
203
 
203
204
                    currentFramework = new RuntimeFramework(runtime, new Version(major, minor));
204
205
                    currentFramework.clrVersion = Environment.Version;
205
206
 
206
 
#if !SILVERLIGHT
207
207
                    if (isMono)
208
208
                    {
209
209
                        MethodInfo getDisplayNameMethod = monoRuntimeType.GetMethod(
414
414
            if (this.AllowAnyVersion || target.AllowAnyVersion)
415
415
                return true;
416
416
 
417
 
            return VersionsMatch(this.ClrVersion, target.ClrVersion)
418
 
                && this.FrameworkVersion.Major >= target.FrameworkVersion.Major
419
 
                && this.FrameworkVersion.Minor >= target.FrameworkVersion.Minor;
 
417
            if (!VersionsMatch(this.ClrVersion, target.ClrVersion))
 
418
                return false;
 
419
 
 
420
            return Runtime == RuntimeType.Silverlight
 
421
                ? this.frameworkVersion.Major == target.FrameworkVersion.Major && this.frameworkVersion.Minor == target.FrameworkVersion.Minor
 
422
                : this.FrameworkVersion.Major >= target.FrameworkVersion.Major && this.FrameworkVersion.Minor >= target.FrameworkVersion.Minor;
420
423
        }
421
424
 
422
425
        #endregion