Cannot decompile CompositeScriptReference GetUrl method

Moderators: Luke Jefferson, Greg.Tillman, Clive Tong

Cannot decompile CompositeScriptReference GetUrl method

Postby meyerovb » Tue May 10, 2011 8:21 pm

Add System.Web.Extensions Version 3.5.0.0
Go to System.Web.UI.CompositeScriptReference
Try to decompile GetUrl method
Get an error


I reported this several years ago actually, I just want to see the inside of that method already!
meyerovb
 
Posts: 13
Joined: Thu Dec 09, 2010 1:04 am

Postby Nigel Morse » Wed May 11, 2011 9:23 am

Hi - you should ask this on the help forum at http://forums.reflector.net
Nigel Morse
 
Posts: 164
Joined: Thu Apr 05, 2007 1:10 pm

Postby RichardD » Wed May 11, 2011 1:15 pm

It's a shame, especially as the .NET 4.0 version works.

The reference source might help:
http://referencesource.microsoft.com/netframework.aspx

The file is installed under the oh-so-obvious path of:
RefSrc\\Source\\Dotnetfx_Win7_3.5.1\\3.5.1\\DEVDIV\\depot\\DevDiv\\releases\\Orcas\\NetFXw7\\ndp\\fx\\src\\xsp\\System\\Web\\Extensions\\ui\\CompositeScriptReference.cs\\1\\CompositeScriptReference.cs

The GetUrl method:

Code: Select all
[SuppressMessage(\"Microsoft.Design\", \"CA1055\", Justification = \"Consistent with other URL properties in ASP.NET.\")]
protected internal override string GetUrl(ScriptManager scriptManager, bool zip) {
    bool isDebuggingEnabled = !scriptManager.DeploymentSectionRetail &&
            ((ScriptMode == ScriptMode.Debug) ||
            (((ScriptMode == ScriptMode.Inherit) || (ScriptMode == ScriptMode.Auto)) &&
            (scriptManager.IsDebuggingEnabled)));
    if (!String.IsNullOrEmpty(Path)) {
        string path = Path;
        if (isDebuggingEnabled) {
            path = GetDebugPath(path);
        }
        if (scriptManager.EnableScriptLocalization &&
            (ResourceUICultures != null) && (ResourceUICultures.Length != 0)) {

            CultureInfo currentCulture = CultureInfo.CurrentUICulture;
            string cultureName = null;
            bool found = false;
            while (!currentCulture.Equals(CultureInfo.InvariantCulture)) {
                cultureName = currentCulture.ToString();
                foreach (string uiCulture in ResourceUICultures) {
                    if (String.Equals(cultureName, uiCulture.Trim(), StringComparison.OrdinalIgnoreCase)) {
                        found = true;
                        break;
                    }
                }
                if (found) break;
                currentCulture = currentCulture.Parent;
            }
            if (found) {
                path = (path.Substring(0, path.Length - 2) + cultureName + \".js\");
            }
        }

        // ResolveClientUrl is appropriate here because the path is consumed by the page it was declared within
        return ClientUrlResolver.ResolveClientUrl(path);
    }
    List<Pair<Assembly, List<Pair<string, CultureInfo>>>> resources =
        new List<Pair<Assembly, List<Pair<string, CultureInfo>>>>();
    Pair<Assembly, List<Pair<string, CultureInfo>>> resourceList = null;
    foreach (ScriptReference reference in Scripts) {
        bool hasPath = !String.IsNullOrEmpty(reference.Path);
        bool isPathBased = hasPath ||
            (!String.IsNullOrEmpty(scriptManager.ScriptPath) && !reference.IgnoreScriptPath);
        Assembly resourceAssembly = hasPath ?
            null :
            (reference.GetAssembly() ?? AssemblyCache.SystemWebExtensions);
        Assembly cacheAssembly = isPathBased ?
            null :
            (reference.GetAssembly() ?? AssemblyCache.SystemWebExtensions);
        CultureInfo culture = reference.DetermineCulture();

        if ((resourceList == null) || (resourceList.First != cacheAssembly)) {
            resourceList = new Pair<Assembly, List<Pair<string, CultureInfo>>>(
            cacheAssembly, new List<Pair<string, CultureInfo>>());
            resources.Add(resourceList);
        }
        string resourceName = null;
        ScriptMode effectiveScriptModeForReference = reference.EffectiveScriptMode;
        bool isDebuggingEnabledForReference =
            (effectiveScriptModeForReference == ScriptMode.Inherit) ?
            isDebuggingEnabled :
            (effectiveScriptModeForReference == ScriptMode.Debug);
        if (isPathBased) {
            if (hasPath) {
                resourceName = reference.GetPath(reference.Path, isDebuggingEnabledForReference);
                if (scriptManager.EnableScriptLocalization && !culture.Equals(CultureInfo.InvariantCulture)) {
                    resourceName = (resourceName.Substring(0, resourceName.Length - 2) +
                        culture.ToString() + \".js\");
                }
            }
            else {
                string name = reference.GetResourceName(reference.Name, resourceAssembly, isDebuggingEnabledForReference);
                resourceName = ScriptReference.GetScriptPath(
                    name, resourceAssembly, culture, scriptManager.ScriptPath);
            }

            // ResolveClientUrl not appropriate here because the handler that will serve the response is not
            // in the same directory as the page that is generating the url. Instead, an absolute url is needed
            // as with ResolveUrl(). However, ResolveUrl() would prepend the entire application root name. For
            // example, ~/foo.js would be /TheApplicationRoot/foo.js. If there are many path based scripts the
            // app root would be repeated many times, which for deep apps or long named apps could cause the url
            // to reach the maximum 1024 characters very quickly. So, the path is combined with the control's
            // AppRelativeTemplateSourceDirectory manually, so that ~/foo.js remains ~/foo.js, and foo/bar.js
            // becomes ~/templatesource/foo/bar.js. Absolute paths can remain as is. The ScriptResourceHandler will
            // resolve the ~/ with the app root using VirtualPathUtility.ToAbsolute().
            if (UrlPath.IsRelativeUrl(resourceName) && !UrlPath.IsAppRelativePath(resourceName)) {
                resourceName = UrlPath.Combine(ClientUrlResolver.AppRelativeTemplateSourceDirectory, resourceName);
            }
        }
        else {
            resourceName = reference.GetResourceName(reference.Name, resourceAssembly, isDebuggingEnabledForReference);
        }
        resourceList.Second.Add(new Pair<string, CultureInfo>(resourceName, culture));
    }
    return ScriptResourceHandler.GetScriptResourceUrl(resources, zip, NotifyScriptLoaded);
}
RichardD
 
Posts: 46
Joined: Wed Aug 20, 2008 6:44 pm


Return to .NET Reflector 7.0 Feedback

Who is online

Users browsing this forum: No registered users and 0 guests