Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functionality to pack and retrieve arbitrary files specified in .dna #688

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rob-oehm-automation
Copy link

Hi @govert

This PR is my attempt to address #331 and adds a File element type to the .dna schema as well as the corresponding code to pack and unpack the files.

By inspection, this code should achieve this, however, I am not sure of the process to generate tests to ensure that this code is working as expected. It looks like the packing tests rely on known-good binary files, what do I need to do to create one of these files with an embedded file?

The main changes are:

  • Adds new FileType to the DnaLibrary xsd schema
  • Adds new DnaFile class for xml serialization
  • Adds new API public static IEnumerable<string> ExcelDnaUtil.GetPackedFileNames()
  • Adds new API public static byte[] ExcelDnaUtil.GetPackedFileBytes(string name)

@CLAassistant
Copy link

CLAassistant commented Mar 29, 2024

CLA assistant check
All committers have signed the CLA.

@govert
Copy link
Member

govert commented Mar 30, 2024

Thank you for the pull request @rob-oehm-automation - I'll have a look.

@tomap
Copy link
Contributor

tomap commented Mar 31, 2024

@rob-oehm-automation I'm interested in understanding your use case. Thank you

@rob-oehm-automation
Copy link
Author

I have a need to load some assemblies dynamically but still want the convenience of distribution via a single xll. .NET dlls packed and then re-extracted are not identical files, I guess the packing process does some IL rewriting so a re-extracted file isn't loaded correctly as a .NET Assembly.

@govert
Copy link
Member

govert commented Apr 2, 2024

Hi @rob-oehm-automation - you say

.NET dlls packed and then re-extracted are not identical files

The assemblies should be identical after extraction - the Excel-DNA build does not do any IL rewriting or any other change. The assemblies are packed in compressed format (this can be disabled in the project file) but when loaded should be 100% identical to the built binary.

It would be easier to use the existing assembly packing mechanism (maybe exposing an access helper) than adding support for general file packing.

In the past I've suggested that add-in libraries should pack any additional files as normal resources into the .NET .dll output, keeping the Excel-DNA packing for the special cases where the library load resolution needs to be done by the Excel-DNA loader.

I'm not completely against adding the more general option - it could be more convenient than the built-in .NET resource management mechanism. But it would be a duplication of that functionality in a sense.

@rob-oehm-automation
Copy link
Author

There must be some issues with my extraction code then. I will investigate that further.

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.

4 participants