diff options
author | t-espave <unknown> | 2011-07-27 16:47:04 -0700 |
---|---|---|
committer | t-espave <unknown> | 2011-07-27 16:47:04 -0700 |
commit | 9951eaeb325bb615aa7c1e22450e5d177c85b513 (patch) | |
tree | 4bda103dbb3383c3585d31a18434b26e8da24154 /BCT | |
parent | 8f8feda4d3270ae78e4c03c34f5af151a2e164c1 (diff) |
solved uri naming issues
Diffstat (limited to 'BCT')
-rw-r--r-- | BCT/BytecodeTranslator/MetadataTraverser.cs | 14 | ||||
-rw-r--r-- | BCT/BytecodeTranslator/Phone/PhoneCodeHelper.cs | 22 | ||||
-rw-r--r-- | BCT/BytecodeTranslator/Phone/PhoneNavigationTraverser.cs | 4 | ||||
-rw-r--r-- | BCT/TranslationPlugins/PhoneControlsPlugin.cs | 50 |
4 files changed, 56 insertions, 34 deletions
diff --git a/BCT/BytecodeTranslator/MetadataTraverser.cs b/BCT/BytecodeTranslator/MetadataTraverser.cs index 389c3684..60a5efb2 100644 --- a/BCT/BytecodeTranslator/MetadataTraverser.cs +++ b/BCT/BytecodeTranslator/MetadataTraverser.cs @@ -106,7 +106,8 @@ namespace BytecodeTranslator { private void trackPhoneApplicationClassname(ITypeDefinition typeDef) {
if (PhoneCodeHelper.PhonePlugin != null && typeDef.isPhoneApplicationClass(sink.host)) {
INamespaceTypeDefinition namedTypeDef = typeDef as INamespaceTypeDefinition;
- string fullyQualifiedName = namedTypeDef.ContainingNamespace.Name.Value + "." + namedTypeDef.Name.Value;
+ // string fullyQualifiedName = namedTypeDef.ContainingNamespace.Name.Value + "." + namedTypeDef.Name.Value;
+ string fullyQualifiedName = namedTypeDef.ToString();
PhoneCodeHelper.setMainAppTypeReference(typeDef);
PhoneCodeHelper.setMainAppTypeName(fullyQualifiedName);
}
@@ -115,10 +116,13 @@ namespace BytecodeTranslator { private void trackPageNameVariableName(ITypeDefinition typeDef) {
if (PhoneCodeHelper.PhonePlugin != null && typeDef.isPhoneApplicationPageClass(sink.host)) {
INamespaceTypeDefinition namedTypeDef = typeDef as INamespaceTypeDefinition;
- string fullyQualifiedName = namedTypeDef.ContainingNamespace.Name.Value + "." + namedTypeDef.Name.Value;
- string uriName = PhoneCodeHelper.getURIBase(PhoneCodeHelper.getXAMLForPage(fullyQualifiedName));
- Bpl.Constant uriConstant= sink.FindOrCreateConstant(uriName);
- PhoneCodeHelper.setBoogieStringPageNameForPageClass(fullyQualifiedName, uriConstant.Name);
+ string fullyQualifiedName = namedTypeDef.ToString();
+ string xamlForClass = PhoneCodeHelper.getXAMLForPage(fullyQualifiedName);
+ if (xamlForClass != null) { // if not it is possibly an abstract page
+ string uriName = PhoneControlsPlugin.getURIBase(xamlForClass);
+ Bpl.Constant uriConstant = sink.FindOrCreateConstant(uriName);
+ PhoneCodeHelper.setBoogieStringPageNameForPageClass(fullyQualifiedName, uriConstant.Name);
+ }
}
}
diff --git a/BCT/BytecodeTranslator/Phone/PhoneCodeHelper.cs b/BCT/BytecodeTranslator/Phone/PhoneCodeHelper.cs index 827eaf3e..20b47046 100644 --- a/BCT/BytecodeTranslator/Phone/PhoneCodeHelper.cs +++ b/BCT/BytecodeTranslator/Phone/PhoneCodeHelper.cs @@ -399,28 +399,6 @@ namespace BytecodeTranslator.Phone { return PhoneCodeHelper.NAV_CALLS.Contains(call.MethodToCall.Name.Value);
}
- /// <summary>
- /// uri is a valid URI but possibly partial (incomplete ?arg= values) and overspecified (complete ?arg=values)
- /// This method returns a base URI
- /// </summary>
- /// <param name="uri"></param>
- /// <returns></returns>
- public static string getURIBase(string uri) {
- // I need to build an absolute URI just to call getComponents() ...
- Uri mockBaseUri = new Uri("mock://mock/", UriKind.RelativeOrAbsolute);
- Uri realUri;
- try {
- realUri = new Uri(uri, UriKind.Absolute);
- } catch (UriFormatException) {
- // uri string is relative
- realUri = new Uri(mockBaseUri, uri);
- }
-
- string str = realUri.GetComponents(UriComponents.Path | UriComponents.StrongAuthority | UriComponents.Scheme, UriFormat.UriEscaped);
- Uri mockStrippedUri = new Uri(str);
- return mockBaseUri.MakeRelativeUri(mockStrippedUri).ToString();
- }
-
private static ITypeReference mainAppTypeRef;
public static void setMainAppTypeReference(ITypeReference appType) {
mainAppTypeRef = appType;
diff --git a/BCT/BytecodeTranslator/Phone/PhoneNavigationTraverser.cs b/BCT/BytecodeTranslator/Phone/PhoneNavigationTraverser.cs index 81e59907..58f45a08 100644 --- a/BCT/BytecodeTranslator/Phone/PhoneNavigationTraverser.cs +++ b/BCT/BytecodeTranslator/Phone/PhoneNavigationTraverser.cs @@ -41,7 +41,7 @@ namespace BytecodeTranslator.Phone { Assignment uriInitAssign = new Assignment() {
Source = new CompileTimeConstant() {
Type = host.PlatformType.SystemString,
- Value = PhoneCodeHelper.getURIBase(mainPageUri),
+ Value = PhoneControlsPlugin.getURIBase(mainPageUri),
},
Type = host.PlatformType.SystemString,
Target = new TargetExpression() {
@@ -281,7 +281,7 @@ namespace BytecodeTranslator.Phone { Assignment currentURIAssign = new Assignment() {
Source = new CompileTimeConstant() {
Type = host.PlatformType.SystemString,
- Value = PhoneCodeHelper.getURIBase(entry.Item3),
+ Value = PhoneControlsPlugin.getURIBase(entry.Item3),
},
Type = host.PlatformType.SystemString,
Target = new TargetExpression() {
diff --git a/BCT/TranslationPlugins/PhoneControlsPlugin.cs b/BCT/TranslationPlugins/PhoneControlsPlugin.cs index 46e93911..e9606a07 100644 --- a/BCT/TranslationPlugins/PhoneControlsPlugin.cs +++ b/BCT/TranslationPlugins/PhoneControlsPlugin.cs @@ -109,10 +109,48 @@ namespace TranslationPlugins { private IDictionary<string, PageStructure> pageStructureInfo;
- public static string getFullyQualifiedControlClass(string controlClass) {
- // TODO do an actual API discovery. The problem will be differencing 7.0 apps from 7.1 apps
- return "System.Windows.Controls." + controlClass;
+ public static string getURILastPath(string uri) {
+ // I need to build an absolute URI just to call getComponents() ...
+ Uri mockBaseUri = new Uri("mock://mock/", UriKind.RelativeOrAbsolute);
+ Uri realUri;
+ try {
+ realUri = new Uri(uri, UriKind.Absolute);
+ } catch (UriFormatException) {
+ // uri string is relative
+ realUri = new Uri(mockBaseUri, uri);
+ }
+
+ string str = realUri.GetComponents(UriComponents.Path | UriComponents.StrongAuthority | UriComponents.Scheme, UriFormat.UriEscaped);
+ Uri mockStrippedUri = new Uri(str);
+ return mockBaseUri.MakeRelativeUri(mockStrippedUri).ToString();
}
+
+ /// <summary>
+ /// uri is a valid URI but possibly partial (incomplete ?arg= values) and overspecified (complete ?arg=values)
+ /// This method returns a base URI
+ /// </summary>
+ /// <param name="uri"></param>
+ /// <returns></returns>
+ public static string getURIBase(string uri) {
+ // I need to build an absolute URI just to call getComponents() ...
+ Uri mockBaseUri = new Uri("mock://mock/", UriKind.RelativeOrAbsolute);
+ Uri realUri;
+ try {
+ realUri = new Uri(uri, UriKind.Absolute);
+ } catch (UriFormatException) {
+ // uri string is relative
+ realUri = new Uri(mockBaseUri, uri);
+ }
+
+ string str = realUri.GetComponents(UriComponents.Path | UriComponents.StrongAuthority | UriComponents.Scheme, UriFormat.UriEscaped);
+ Uri mockStrippedUri = new Uri(str);
+ return mockBaseUri.MakeRelativeUri(mockStrippedUri).ToString();
+ }
+
+ //public static string getFullyQualifiedControlClass(string controlClass) {
+ // // TODO do an actual API discovery. The problem will be differencing 7.0 apps from 7.1 apps
+ // return "System.Windows.Controls." + controlClass;
+ //}
public PhoneControlsPlugin(string configFile) {
pageStructureInfo = new Dictionary<string, PageStructure>();
@@ -152,8 +190,10 @@ namespace TranslationPlugins { }
private void setPageAsMainPage(string pageXAML) {
-
- KeyValuePair<string,PageStructure> mainPageClass= pageStructureInfo.FirstOrDefault(keyValue => keyValue.Value.PageXAML == pageXAML);
+ int lastDirPos= pageXAML.LastIndexOf('/');
+ if (lastDirPos != -1)
+ pageXAML = pageXAML.Substring(lastDirPos+1);
+ KeyValuePair<string,PageStructure> mainPageClass= pageStructureInfo.FirstOrDefault(keyValue => keyValue.Value.PageXAML.ToLower() == pageXAML.ToLower());
if (mainPageClass.Equals(default(KeyValuePair<string, PageStructure>))) {
// the main page doesn't exist because it has no tracked controls. While we cannot track those controls, create a page struct for it
} else {
|