143
143
return TargetFrameworkToolsVersion.V4_0;
146
bool HackyCheckForPLPCompatibility (TargetFrameworkMoniker fxId)
146
static bool ProfileMatchesPattern (string profile, string pattern)
148
int profile, this_profile;
150
if (fxId.Profile == null || fxId.Profile.Length < 8 || !int.TryParse (fxId.Profile.Substring (7), out profile))
153
switch (this.id.Identifier) {
154
case TargetFrameworkMoniker.ID_NET_FRAMEWORK:
155
if (new Version (fxId.Version).CompareTo (new Version (this.id.Version)) > 0)
158
return profile >= 1 && profile <= 3; // Profile4 does not support .NETFramework
159
case TargetFrameworkMoniker.ID_MONOTOUCH:
160
case TargetFrameworkMoniker.ID_MONODROID:
161
return profile >= 1 && profile <= 3;
162
case TargetFrameworkMoniker.ID_PORTABLE:
163
if (this.id.Profile == null || this.id.Profile.Length < 8 || !int.TryParse (this.id.Profile.Substring (7), out this_profile))
166
switch (this_profile) {
168
case 2: return profile == 2;
169
case 3: return profile == 3;
170
case 4: return profile == 4;
171
default: return false;
148
if (string.IsNullOrEmpty (pattern))
149
return string.IsNullOrEmpty (profile);
151
int star = pattern.IndexOf ('*');
157
if (string.IsNullOrEmpty (profile))
160
var prefix = pattern.Substring (0, star);
161
return profile.StartsWith (prefix);
164
return profile == pattern;
167
[Obsolete ("Use CanReferenceAssembliesTargetingFramework() instead")]
178
168
public bool IsCompatibleWithFramework (TargetFrameworkMoniker fxId)
180
// FIXME: this is a hack which should really be done using the xml definitions for each .NETPortable profile
181
if (fxId.Identifier == ".NETPortable" && fxId.Version == "4.0")
182
return HackyCheckForPLPCompatibility (fxId);
184
return fxId.Identifier == this.id.Identifier
185
&& new Version (fxId.Version).CompareTo (new Version (this.id.Version)) <= 0;
170
return CanReferenceAssembliesTargetingFramework (fxId);
173
public bool CanReferenceAssembliesTargetingFramework (TargetFrameworkMoniker fxId)
175
var fx = Runtime.SystemAssemblyService.GetTargetFramework (fxId);
177
return fx != null && CanReferenceAssembliesTargetingFramework (fx);
181
/// Determines whether projects targeting this framework can reference assemblies targeting the framework specified by fx.
183
/// <returns><c>true</c> if projects targeting this framework can reference assemblies targeting the framework specified by fx; otherwise, <c>false</c>.</returns>
184
/// <param name="fx">The target framework</param>
185
public bool CanReferenceAssembliesTargetingFramework (TargetFramework fx)
187
foreach (var sfx in fx.SupportedFrameworks) {
188
if (sfx.Identifier != id.Identifier)
191
if (!ProfileMatchesPattern (id.Profile, sfx.Profile))
194
var version = new Version (id.Version);
196
if (version >= sfx.MinimumVersion && version <= sfx.MaximumVersion)
200
// FIXME: this is a hack for systems w/o Portable Class Library definitions
201
if (fx.Id.Identifier == TargetFrameworkMoniker.ID_PORTABLE) {
202
switch (id.Identifier) {
203
case TargetFrameworkMoniker.ID_NET_FRAMEWORK:
204
return new Version (fx.Id.Version).CompareTo (new Version (id.Version)) <= 0;
205
case TargetFrameworkMoniker.ID_MONOTOUCH:
206
case TargetFrameworkMoniker.ID_MONODROID:
211
return fx.Id.Identifier == id.Identifier && new Version (fx.Id.Version).CompareTo (new Version (id.Version)) <= 0;
188
214
internal string GetCorlibVersion ()