GithubHelp home page GithubHelp logo

Comments (9)

gaelcolas avatar gaelcolas commented on July 17, 2024

[edited]
So to the comment/question: "hash table can only be added to another hash table"
Yes, that's by design, otherwise you can't really predict how it should behave...
If it's different type (broad types, i.e. Key/Name collections/Scalar/arrays of scalar), the reference object should be used...

I will now have a look at the branch you mention (just wanted to edit my comment)

from datum.

gaelcolas avatar gaelcolas commented on July 17, 2024

Yep, that's a bug.

from datum.

gaelcolas avatar gaelcolas commented on July 17, 2024

Oh, and surprise, it seems to be an issue with the cache... That's why it was so hard to consistently reproduce!
If you look closely, the RSOP are generated fine, but the compilation fails...
If you load a fresh datum structure and tries the lookup -PropertyPath 'FilesAndFolders' -Node $Node -DatumTree $Datum it works fine...

Then try to build.ps1 (leave it to fail) and then try again that line above... it fails.
Reset the cache of the Datum module:

$m = get-module datum
&$m { $script:FileProviderDataCache = $null }
lookup -PropertyPath 'FilesAndFolders' -Node $Node -DatumTree $Datum

Now it works again...

Definitely a bug, look for the root cause, probably in the cache. Will let you know when I get an idea how to fix this...

from datum.

gaelcolas avatar gaelcolas commented on July 17, 2024

More specifically, it's the cache for the FileServer Role.
When it works it looks like this:

PS C:\src\DscWorkshop\DscSample> &$m { $script:FileProviderDataCache['C:\src\DscWorkshop\DscSample\DSC_ConfigData\Roles\FileServer.yml'].value.FilesAndFolders.items.ToString() }
System.Object[]

When it fails:

PS C:\src\DscWorkshop\DscSample> &$m { $script:FileProviderDataCache['C:\src\DscWorkshop\DscSample\DSC_ConfigData\Roles\FileServer.yml'].value.FilesAndFolders.items.ToString() }System.Collections.Generic.List`1[System.Object]

I wonder when this is getting "corrupted"...

Most likely, there's a Write-Output somewhere (might be implicit), that is not using -NoEnumerate.

from datum.

gaelcolas avatar gaelcolas commented on July 17, 2024

I've got a quick fix for that issue (I think).
Hit me up on Skype when you're available.

from datum.

gaelcolas avatar gaelcolas commented on July 17, 2024

Have a look there:
https://ci.appveyor.com/project/gaelcolas/datum/builds/21791313/artifacts
Unzip in your BuildOutput\modules of your project and rebuild without a resolve-dependency.

That should fix it.

from datum.

raandree avatar raandree commented on July 17, 2024

Thanks @gaelcolas, I came up with a similar thing but did not really understand why ForEach-Object refreshed the $_ variable while .ForEach did not. do you know what happens inside of PowerShell here?

from datum.

gaelcolas avatar gaelcolas commented on July 17, 2024

Not really...
Even when the array was empty it was calling the Foreach method, but because there was no item, $_ did get updated with the current collection's item (should have been $null), so it used a parent loop's $_, being a scalar... That you can't merge with a hashtable...

Very weird, but I've seen that before. Just never bothered going down that rabbit hole... a bit of a shame as sending stuff through the pipeline has a cost and the Foreach method is meant to be faster, but those are rarely big merges so the impact should be minimal, even for big configs.

Those part are due for a re-write anyway, just not my priority for now as we discussed previously.

from datum.

raandree avatar raandree commented on July 17, 2024

If you have concerns about performance, let's use the foreach keyword instead of Foreach-Object cmdlet. This should not be much slower than .foreach.

from datum.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.