Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@twsouthwick
Copy link
Collaborator

No description provided.

}

AppDomain.CurrentDomain.AssemblyLoad += CurrentDomain_AssemblyLoad;
private void Initialize()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't figure out how to lazily load them since we need to actually load them into the current context without cycles... so I removed the lazily initialization

@github-actions
Copy link

github-actions bot commented Mar 5, 2025

Test Results

21 tests  ±0   18 ✅ ±0   20s ⏱️ +7s
 2 suites ±0    3 💤 ±0 
 2 files   ±0    0 ❌ ±0 

Results for commit a391942. ± Comparison against base commit 8902767.

♻️ This comment has been updated with latest results.

@birojnayak
Copy link
Collaborator

let me take this change locally and test the ajax toolkit controls before shipping...

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR implements a new mechanism for loading controls by detecting assemblies with tag prefixes. Key changes include:

  • Replacing the lazy-loaded assembly management with immediate initialization and control scanning in DynamicControlCollection.
  • Updating the attribute lookup in WebForms-related files to use a generic extension method (HasAttribute).
  • Adjusting the StaticControlCollection to use the generic attribute check and marking helper methods as static.

Reviewed Changes

File Description
src/Compiler.Dynamic/DynamicControlCollection.cs Refactors assembly loading by introducing Initialize, SearchForControls, and LoadMetadataReference methods, and switches to using ImmutableDictionary-based storage for controls and metadata references.
src/WebForms/AssemblyAttributeUtility.cs Replaces the string-based attribute lookup with a new generic version for improved type-safety.
src/WebForms/PreApplicationStartMethodExtensions.cs Updates the attribute check to use the new generic HasAttribute method.
src/Compiler.Dynamic/StaticControlCollection.cs Updates the control scanning logic to use the generic HasAttribute method and marks the helper method static.

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/Compiler.Dynamic/StaticControlCollection.cs:37

  • [nitpick] The method HasTagPrefix was updated to be static; please ensure that all its call sites are correctly updated to reflect its static nature.
private static bool HasTagPrefix(AssemblyMetadata assembly)

@birojnayak
Copy link
Collaborator

PR Overview

This PR implements a new mechanism for loading controls by detecting assemblies with tag prefixes. Key changes include:

* Replacing the lazy-loaded assembly management with immediate initialization and control scanning in DynamicControlCollection.

* Updating the attribute lookup in WebForms-related files to use a generic extension method (HasAttribute).

* Adjusting the StaticControlCollection to use the generic attribute check and marking helper methods as static.

Reviewed Changes

File Description
src/Compiler.Dynamic/DynamicControlCollection.cs Refactors assembly loading by introducing Initialize, SearchForControls, and LoadMetadataReference methods, and switches to using ImmutableDictionary-based storage for controls and metadata references.
src/WebForms/AssemblyAttributeUtility.cs Replaces the string-based attribute lookup with a new generic version for improved type-safety.
src/WebForms/PreApplicationStartMethodExtensions.cs Updates the attribute check to use the new generic HasAttribute method.
src/Compiler.Dynamic/StaticControlCollection.cs Updates the control scanning logic to use the generic HasAttribute method and marks the helper method static.

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)

too much verbose ... ha ha..

@birojnayak
Copy link
Collaborator

So we are able to detect the TagPrefixAttribute via HasControls for assembly present in the bin folder. But those are never added to _controls because the CurrentDomain_AssemblyLoad never gets called for dll which are part of the bin folder. So I added explicitly after _context.LoadFromAssemblyPath(file); , but in the WebFormsCompilerExtension where we are reading assemblies to register tag, again it's failing. You can re-create using the sample https://github.com/birojnayak/CoreWebForms/tree/AJAXToolKit , just copy the accordion.aspx file and you can build ajaxtoolkit.dll from here

            .Configure<IMetadataProvider>((options, metadata) =>
            {
                foreach (var control in metadata.ControlAssemblies)
                {
                    foreach (var tag in control.GetCustomAttributes<TagPrefixAttribute>())
                    {
                        options.DefaultTagNamespaceRegisterEntries.Add(new(tag.TagPrefix, tag.NamespaceName, control.FullName));
                    }
                }
            });

@twsouthwick
Copy link
Collaborator Author

It loads the WebForms.SqlClient library just fine this way so I do see it working. Can you create a branch that just works to try it out so I don't have to build extra things? i.e. include the .dll in the branch. I just want to just run it

@birojnayak
Copy link
Collaborator

It loads the WebForms.SqlClient library just fine this way so I do see it working. Can you create a branch that just works to try it out so I don't have to build extra things? i.e. include the .dll in the branch. I just want to just run it

ok.. let me do that..

Copy link
Collaborator

@birojnayak birojnayak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approving as it find controls with tag prefix on dll's. As discussed, we can incrementally see if rendering would work and take actions accordingly.

@twsouthwick twsouthwick merged commit 1963f70 into main Mar 6, 2025
9 checks passed
@twsouthwick twsouthwick deleted the load-controls branch March 6, 2025 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants