-
Notifications
You must be signed in to change notification settings - Fork 19
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 external DISM generations support. Fixes #5 & #25. #38
Conversation
… for use with the wrapped DISM API.
@josemesona, I removed my previous fork and started over from scratch in an effort to clean up my branch (and all the changes therein), and better familiarize myself not only with Git, but also GitHub. Now that I'm a bit more familiar, I've created a new fork to "start clean", so to speak, and re-added the Utilities class we've talked about in a separate branch. Hopefully this is cleaner and easier to work with. I know you were interested in modifying the name (from "Utilities" to "DismUtilities"), and potentially integrating some of these changes into the Dism.Initialize() method. I've made the "DismUtilities" change, but haven't done anything else, as I also know this wrapper preserves the original native API mapping, and doesn't expand upon it. I do like the fact that this managed API only wraps the native one, and leaves expanded functionality aside. Perhaps expanded functionality, such as this DISM generational library support, should remain in a "Utilities" (or other similar) classes, to preserve the clean mapping of the native API? Ultimately, this decision is up to you. Feel free to modify this branch as you see fit to best integrate with this library. If you'd prefer I make the changes, just let me know how you'd like to see it implemented, and I can make another branch for you to review. Once again, thanks for your patience while I'm getting up to speed with Git & GitHub. |
I really like this functionality but again I'm just concerned that it moves away from being a pure wrapper. If you make public static partial class DismApi
{
public static void InitializeEx(
DismLogLevel logLevel,
string logFilePath,
string scratchDirectory,
DismGeneration generation)
{
// Call DismUtilities.LoadDismGenerationLibrary(), throw an exception if it returns false
// Call Initialize(logLevel, logFIlePath, scratchDirectory)
}
} Be sure to unload the library in This leaves |
I think that sounds like a good plan. I like the idea of using Ex methods, I just need to implement them. I'll work to have something implemented shortly and update. |
…expose initializing DISM with generational DISM library support.
I modified the branch as we discussed. A couple quick points:
I wanted to make these changes for further discussion before being prepared for merging; thus, I need to modify some comments (specifically in DismUtilities) to be more pertinent depending on what implementation we settle on. I'm not thrilled by having a Property in DismApi to represent the DISM Generation that's loaded, because it feels like we're polluting the "pure" nature of your wrapper cleanly mapping the Win32 DISM API. On the other hand, I need to store whether or not a DISM Generation library was loaded, and this implementation also lets the user check what's in use, which (I think) is useful. What are you thoughts, now with a more complete version of what we had discussed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay, I was out of town. Looks great!
src/Microsoft.Dism/DismApi.cs
Outdated
/// <summary> | ||
/// Represents the DISM Generational Library initialized for use with the DismApi Wrapper (via InitializeEx()). Returns the specific DismGeneration in use; otherwise, returns DismGeneration.NotFound. | ||
/// </summary> | ||
public static DismGeneration DismGenerationInitialized |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this internal, an autoproperty, and set a initial value so you can get rid of the dismGenerationInitialized
field and setting it in Initialize
internal static DismGeneration DismGenerationInitialized { get; set; } = DismGeneration.None;
src/Microsoft.Dism/DismApi.cs
Outdated
/// <exception cref="DismException">When a failure occurs.</exception> | ||
public static void InitializeEx(DismLogLevel logLevel) | ||
{ | ||
DismGeneration dismGeneration = DismUtilities.GetLatestDismGeneration(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably needs to do nothing if its already been initialized right?
if(DismGenerationInitialized != DismGeneration.None)
{
return;
}
Or maybe even throw, I'm not sure what Initialize
will do if you accidentally call it twice...
…InitializeEx() functions and added a new Exception to handle calling InitializeEx() when a DISM Generation library is already loaded.
No problem -- everybody is busy. :) Good call on the Automatic Property. I made that change, and cleaned up the InitializeEx() methods as well, so the overloads cascade instead of repeating the same logic. I also added an additional Exception handler, in the event the user does try to InitializeEx() after already loading a DISM Generation library and before freeing it (Shutdown()). Any other thoughts or changes you can think of? EDIT: I should note, if/when we're comfortable with the "DISM Generation" changes, I'll modify the DismUtilities comments to better reflect the changes we've agreed upon, and submit that as a change as well for review. |
I've pushed a few commits, double check them and I'll merge! |
Looks great! I like moving the expanded functionality in DismApiEx, good idea. EDIT: If you're waiting on me to review or approve the changes, I looked, but I can't approve changes on my own pull request. (Still relatively new to GitHub.) |
That's fine, I was just waiting for you to comment. Thanks for the contribution, I'll push a package. |
Package will be available at https://www.nuget.org/packages/Microsoft.Dism/1.6.446 in about 10 minutes (it is being "validated" by nuget.org) |
Adds a "DismUtilities" class that adds support for external DISM libraries across DISM generations, which allows the user to (optionally) load external DISM libraries instead of defaulting to look for DISM on the local system.