-
Notifications
You must be signed in to change notification settings - Fork 42
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
Class / Module Attributes lost on import #230
Comments
Note: when I manually import, it appears to load just fine, and keeps the attributes; when using the addin, they're lost. |
When you do the manual import are you using the |
Ok, some more troubleshooting. When I manually import, I need the following added so that it is correctly loaded into the IDE as a class and not a regular module: VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
End
Attribute VB_Name = "clsSillyName"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Compare Database Which will break on import, and it is subsequently loaded as a "plain" module, and not a class. As I poke around, I see there's not a separate |
Good question: because I'm in a hurry, I just used the IDE; I'll give |
Well, did It does appear to respect the |
Access uses the same object collection to export standard and class modules, and automatically figures out which type to use when importing the source file. This add-in project, for example, uses both standard and class modules, and they are always built correctly. My hunch is that the leading attribute lines is what signals If you would like to create a minimal database that demonstrates the issue, I could probably do a little testing on my end as well. I would like the add-in to support the hidden attributes. I am familiar with them, but haven't really used them in my projects. |
Sure thing; it actually works for a PR I was going to make for clsConcat; I'll tidy that up and send it your way :) |
see #232 |
Thanks for the further details on this. I was able to reproduce the issue on my end. The export file includes the attributes, but they seem to be lost on import. I have some ideas on how to work with this... |
As a side note, there does not appear to be any way to import an object class module to an existing object using VBE, so this technique could not be used with forms or reports. That being said, we should be able to do this for class modules by overlaying a VBE import after importing the object. I think I will also add this as a non-default option since it will involve slightly more overhead when checking for changes since changes to attributes are not reflected in the source code. |
This is a good idea; I don't think that Forms/reports can even have I wonder if a sort of |
My thought exactly! If no hidden attributes are detected, then we can simply use the standard import. Otherwise we will use the alternate VBE import after adding the header section in a temporary file based on the |
The upshot of this might also make the exported files more portable, too. For instance, if I import the raw exported files from the addin via the IDE > import file dialog, classes will invariably be imported as a plain module. If the class info as shown below is kept with the export (or manually added later), that works perfectly (though...breaks the This also would allow users who get third party addons modules/classes and import them, they don't need to do / know much other than they plop it in the I am curious, though, as the |
Hmm... Maybe we should always use VBE export for modules... Is there anything that would be in the The other nice thing about the native VBE export files is that you can drag them and drop them directly into a project in the IDE and they import automatically. They would definitely be more portable. |
A long while back I came across a SO thread going over it, but abandoned the idea when I found the legacy addin. Upon reread, looks like one poster handles query adjustment, too.......... |
This change allows us to utilize hidden VBE attributes in source code to define things like default members and description text. See #230 for additional details.
I have just rolled out this change to the |
A side benefit of this change is that it has slightly improved the performance of the code export, especially when large numbers of code modules are involved. Also note that if you manually import hidden attributes to a code module, and you have Fast Save turned on, you will want to do a full export to make sure those changes get saved to the source files. The change detection only looks for changes in the VBA code. It does not export each object and compare the file hash to pick up on the changes to hidden attributes. I tried that initially, but it was many times slower than just checking the VBA source behind the object. Since most people will manage these changes to hidden attributes using the source files themselves, and build from source to bring them into the project, I don't really think this will be a problem. |
I'll check them out momentarily! |
Well, like all good ideas I have, this one's got some bumps. When using a prior version to build the db from source, the header info makes things unhappy. This may be an issue when others try to build. Perhaps we may need to release a new version soon with this feature to avoid that too much? There have been some other improvements, too, so may be a good time. |
Yes, this is definitely a "breaking change" in the sense that it will not be compatible with versions that use the One thing that we probably should add is a version check that does not allow a build using files from an incompatible version. With this in mind, perhaps this should be released as version 3.4.0, and only build when the exported version is 3.4.0 or greater. (I am thinking that the merge functionality that I am currently working on will be released as version 4.0.0 since it adds a major functionality change.) |
Success! Looks like they export / import fine on the VCS repo. I had to check out commit d031557 , remove the header from Which, brings me to my next request: if you're going to manage the main repo for this (I applaud it, and welcome/ thank you for heading it up, because it means less for me/others to do), if you could do work on other branches, and then merge them into dev when they're done? That way, users/me won't have to wonder what the new table Anyway, the preservation of attributes works! So, I think we can close this, unless you've got other improvements that need to happen. |
I agree! With the other BOM issues and the like, I think this is a great idea. If 3.4.0 is released, we should remove the translation / conflict forms from the code base and put them in their respective branches, as I think they may distract from the 'working' base, even if most users won't see them. |
Sounds good. Sorry about the extra clutter with the new features in progress.... Initially I was thinking I would just slowly work them into the main As a side note, I am really enjoying the ability to do this kind of branched development work in Microsoft Access! That "build from source" concept has truly revolutionized the way I do database development! 😄 |
These objects are being implemented in specific feature branches which will be rolled into `dev` when they are completed. See discussion in #230
Yes; with the legacy VCS me and a few others on my team were able to rapidly add in some new features between the two of us that wouldn't have been possible before. With the addin, the skids are greased, and it's even easier! |
As I have been doing some testing of this; I have been finding some issues with reverting old code; namely pre/post this implementation. I'm wondering if the performance hit to check which version of the file is being imported would be worth it or not, at least as a non-default option. |
Actually, after more testing, we probably need to revisit this, possibly reopen and implement detection. Worst case, this may need to be combined into milestone 4.0. I still think the files should export with the new I've found a bunch of cases where if you rollback changes to a class/module in git the import will break things, quite often. Some thoughts on how to speed up building based on whether In order from what I think might lead to the fastest build to the slowest, or most desirable to least:
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
End
Attribute VB_Name = "clsSillyName"
|
@hecon5 - Thanks for taking the time to flesh out these thoughts! I have been thinking over this as well over the past few days, and I think I would like to expand upon No. 2 in your list of options. Currently we are rewriting the UTF-8 file as ANSI (system encoding) just before importing anyway, so this gives us the perfect opportunity to check the first 10 lines for the header information, and add it in, if necessary, when rewriting the file. Since we are already doing the file rewrite, I don't think we should see much of a performance penalty. I like this approach because going forward, there will always be both ways of exporting a code module. Although this add-in will exclusively use the VBE Export, the source files it interacts with could be in either format. This might be because they were created using an older version of this add-in, or from tool that uses the |
I was thinking, another way (twofer?) would be to use a different extension, which could further accelerate import detection. SO Answer for File Types, as this also seems to be more inline with the IDE's Import, too: If the file is While this may lead to rename headaches, it also makes naming more consistent with the rest of the Office IDE ecosystem, makes detection easier, importing easier, and if you do end up rolling back a change, you're not causing yourself a ton of angst and headaches when your class imports as a standard module. |
I do like the idea of moving to the |
This is more consistent with the default IDE behavior and file naming conventions. See #230
This allows us to natively import legacy SaveAsText modules and classes, as well as VBE modules and classes. The VBE header is dynamically added if needed. Closes #230
Automatic header detection has now been implemented! VBE or legacy |
Export / import doesn't seem to be working for me after testing, not sure what happened, because it was working. |
Doing some more testing, but a class exported with the legacy [Edit] |
I've noticed that when I have attributes in my modules, they're lost when imported.
Specifically, default member (
Attribute FunctionName.VB_UserMemId = 0
is lost, as are any descriptions.They do not show up when exported, either.
See BA – Attributes for what "should" be happening,
HERE and RD's Example Use are a few more examples.
The text was updated successfully, but these errors were encountered: