├── ALCLoader
├── build.ps1
├── src
│ ├── ALCLoader.Shared
│ │ ├── ALCLoader.Shared.csproj
│ │ ├── SharedUtil.cs
│ │ └── LoadContext.cs
│ └── ALCLoader
│ │ ├── ConvertToNewtonsoftJsonCommand.cs
│ │ ├── ConvertToYamlDotNetCommand.cs
│ │ └── ALCLoader.csproj
├── module
│ ├── ALCLoader.psd1
│ └── ALCLoader.psm1
└── README.md
├── ALCResolver
├── build.ps1
├── src
│ ├── ALCResolver.Private
│ │ ├── Json.cs
│ │ ├── Yaml.cs
│ │ ├── ALCResolver.Private.csproj
│ │ └── SharedUtil.cs
│ └── ALCResolver
│ │ ├── ConvertToYamlDotNetCommand.cs
│ │ ├── ConvertToNewtonsoftJsonCommand.cs
│ │ ├── ALCResolver.csproj
│ │ └── OnImportAndRemove.cs
├── module
│ └── ALCResolver.psd1
└── README.md
├── ALCScriptModule
├── build.ps1
├── src
│ └── ALCScriptModule
│ │ ├── ALCScriptModule.csproj
│ │ └── LoadContext.cs
├── module
│ ├── ALCScriptModule.psd1
│ └── ALCScriptModule.psm1
└── README.md
├── ALCScriptLoadContext
├── build.ps1
├── src
│ └── ALCScriptLoadContext
│ │ └── ALCScriptLoadContext.csproj
├── module
│ ├── ALCScriptLoadContext.psd1
│ └── ALCScriptLoadContext.psm1
└── README.md
├── ALCPureScriptModule
├── module
│ ├── ALCPureScriptModule.psd1
│ └── ALCPureScriptModule.psm1
├── build.ps1
└── README.md
├── README.md
├── .gitignore
├── test.ps1
└── common.ps1
/ALCLoader/build.ps1:
--------------------------------------------------------------------------------
1 | . $PSScriptRoot/../common.ps1
2 |
3 | Invoke-ModuleBuild -Path $PSScriptRoot
4 |
--------------------------------------------------------------------------------
/ALCResolver/build.ps1:
--------------------------------------------------------------------------------
1 | . $PSScriptRoot/../common.ps1
2 |
3 | Invoke-ModuleBuild -Path $PSScriptRoot
4 |
--------------------------------------------------------------------------------
/ALCScriptModule/build.ps1:
--------------------------------------------------------------------------------
1 | . $PSScriptRoot/../common.ps1
2 |
3 | Invoke-ModuleBuild -Path $PSScriptRoot
4 |
--------------------------------------------------------------------------------
/ALCScriptLoadContext/build.ps1:
--------------------------------------------------------------------------------
1 | . $PSScriptRoot/../common.ps1
2 |
3 | Invoke-ModuleBuild -Path $PSScriptRoot
4 |
--------------------------------------------------------------------------------
/ALCScriptLoadContext/src/ALCScriptLoadContext/ALCScriptLoadContext.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ALCScriptModule/src/ALCScriptModule/ALCScriptModule.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net472;net5.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/ALCResolver/src/ALCResolver.Private/Json.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | // We can reference our ALC dependency directly
4 | using Newtonsoft.Json;
5 |
6 | namespace ALCResolver.Private;
7 |
8 | internal static class Json
9 | {
10 | public static string ConvertToJson(Dictionary data)
11 | {
12 | SharedUtil.AddAssemblyInfo(typeof(JsonConvert), data);
13 |
14 | return JsonConvert.SerializeObject(
15 | data,
16 | Formatting.Indented);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ALCResolver/src/ALCResolver.Private/Yaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | // We can reference our ALC dependency directly
4 | using YamlDotNet.Serialization;
5 |
6 | namespace ALCResolver.Private;
7 |
8 | internal static class Yaml
9 | {
10 | public static string ConvertToYaml(Dictionary data)
11 | {
12 | SharedUtil.AddAssemblyInfo(typeof(SerializerBuilder), data);
13 |
14 | SerializerBuilder builder = new SerializerBuilder();
15 | ISerializer serializer = builder.Build();
16 | return serializer.Serialize(data);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ALCLoader/src/ALCLoader.Shared/ALCLoader.Shared.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | net472;net5.0
6 |
7 | 10.0
8 |
9 | enable
10 |
11 |
12 |
13 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/ALCLoader/src/ALCLoader.Shared/SharedUtil.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Reflection;
4 | #if NET5_0_OR_GREATER
5 | using System.Runtime.Loader;
6 | #endif
7 |
8 | namespace ALCLoader.Shared;
9 |
10 | internal class SharedUtil
11 | {
12 | public static void AddAssemblyInfo(Type type, Dictionary data)
13 | {
14 | Assembly asm = type.Assembly;
15 |
16 | data["Assembly"] = new Dictionary()
17 | {
18 | { "Name", asm.GetName().FullName },
19 | #if NET5_0_OR_GREATER
20 | { "ALC", AssemblyLoadContext.GetLoadContext(asm)?.Name },
21 | #endif
22 | { "Location", asm.Location }
23 | };
24 | }
25 | }
--------------------------------------------------------------------------------
/ALCResolver/src/ALCResolver.Private/ALCResolver.Private.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net472;net5.0
5 | 10.0
6 | enable
7 |
8 |
9 |
10 |
13 |
14 |
15 |
16 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/ALCResolver/src/ALCResolver.Private/SharedUtil.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Reflection;
4 | #if NET5_0_OR_GREATER
5 | using System.Runtime.Loader;
6 | #endif
7 |
8 | namespace ALCResolver.Private;
9 |
10 | internal class SharedUtil
11 | {
12 | public static void AddAssemblyInfo(Type type, Dictionary data)
13 | {
14 | Assembly asm = type.Assembly;
15 |
16 | data["Assembly"] = new Dictionary()
17 | {
18 | { "Name", asm.GetName().FullName },
19 | #if NET5_0_OR_GREATER
20 | { "ALC", AssemblyLoadContext.GetLoadContext(asm)?.Name },
21 | #endif
22 | { "Location", asm.Location }
23 | };
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ALCLoader/module/ALCLoader.psd1:
--------------------------------------------------------------------------------
1 | @{
2 | RootModule = 'ALCLoader.psm1'
3 | ModuleVersion = '1.0.0'
4 | GUID = '7b99120d-e9cc-4808-a607-871fd42d376c'
5 | Author = 'Jordan Borean'
6 | CompanyName = 'Community'
7 | Copyright = '(c) 2023 Jordan Borean. All rights reserved.'
8 | Description = 'ALC Loader example'
9 | PowerShellVersion = '5.1'
10 | DotNetFrameworkVersion = '4.7.2'
11 | TypesToProcess = @()
12 | FormatsToProcess = @()
13 | NestedModules = @()
14 | FunctionsToExport = @()
15 | CmdletsToExport = @(
16 | 'ConvertTo-NewtonsoftJson'
17 | 'ConvertTo-YamlDotNet'
18 | )
19 | VariablesToExport = @()
20 | AliasesToExport = @()
21 | PrivateData = @{
22 | PSData = @{}
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ALCScriptModule/module/ALCScriptModule.psd1:
--------------------------------------------------------------------------------
1 | @{
2 | RootModule = 'ALCScriptModule.psm1'
3 | ModuleVersion = '1.0.0'
4 | GUID = 'c54ad6bd-2e14-4768-9d80-6f8f2c28cd30'
5 | Author = 'Jordan Borean'
6 | CompanyName = 'Community'
7 | Copyright = '(c) 2023 Jordan Borean. All rights reserved.'
8 | Description = 'ALC with Script Module'
9 | PowerShellVersion = '5.1'
10 | DotNetFrameworkVersion = '4.7.2'
11 | TypesToProcess = @()
12 | FormatsToProcess = @()
13 | NestedModules = @()
14 | FunctionsToExport = @(
15 | 'ConvertTo-NewtonsoftJson'
16 | 'ConvertTo-YamlDotNet'
17 | )
18 | CmdletsToExport = @()
19 | VariablesToExport = @()
20 | AliasesToExport = @()
21 | PrivateData = @{
22 | PSData = @{}
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ALCScriptLoadContext/module/ALCScriptLoadContext.psd1:
--------------------------------------------------------------------------------
1 | @{
2 | RootModule = 'ALCScriptLoadContext.psm1'
3 | ModuleVersion = '1.0.0'
4 | GUID = '911143c1-f652-458c-af65-bcf3b8c64183'
5 | Author = 'Jordan Borean'
6 | CompanyName = 'Community'
7 | Copyright = '(c) 2024 Jordan Borean. All rights reserved.'
8 | Description = 'ALC with Script Module that uses the LoadContext directly'
9 | PowerShellVersion = '5.1'
10 | DotNetFrameworkVersion = '4.7.2'
11 | TypesToProcess = @()
12 | FormatsToProcess = @()
13 | NestedModules = @()
14 | FunctionsToExport = @(
15 | 'Get-MsalToken'
16 | )
17 | CmdletsToExport = @()
18 | VariablesToExport = @()
19 | AliasesToExport = @()
20 | PrivateData = @{
21 | PSData = @{}
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ALCPureScriptModule/module/ALCPureScriptModule.psd1:
--------------------------------------------------------------------------------
1 | @{
2 | RootModule = 'ALCPureScriptModule.psm1'
3 | ModuleVersion = '1.0.0'
4 | GUID = 'e77b5490-ff5b-4d71-9c0c-e33d32ceb82b'
5 | Author = 'Jordan Borean'
6 | CompanyName = 'Community'
7 | Copyright = '(c) 2023 Jordan Borean. All rights reserved.'
8 | Description = 'ALC with Script Module'
9 | PowerShellVersion = '5.1'
10 | DotNetFrameworkVersion = '4.7.2'
11 | TypesToProcess = @()
12 | FormatsToProcess = @()
13 | NestedModules = @()
14 | FunctionsToExport = @(
15 | 'ConvertTo-NewtonsoftJson'
16 | 'ConvertTo-YamlDotNet'
17 | )
18 | CmdletsToExport = @()
19 | VariablesToExport = @()
20 | AliasesToExport = @()
21 | PrivateData = @{
22 | PSData = @{}
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ALCResolver/module/ALCResolver.psd1:
--------------------------------------------------------------------------------
1 | @{
2 | RootModule = if ($PSEdition -eq 'core') { 'bin/net5.0/ALCResolver.dll' } else { 'bin/net472/ALCResolver.dll' }
3 | ModuleVersion = '1.0.0'
4 | GUID = '31bb040b-32c8-4c89-a65e-876222ec94bc'
5 | Author = 'Jordan Borean'
6 | CompanyName = 'Community'
7 | Copyright = '(c) 2023 Jordan Borean. All rights reserved.'
8 | Description = 'ALC Resolver example'
9 | PowerShellVersion = '5.1'
10 | DotNetFrameworkVersion = '4.7.2'
11 | TypesToProcess = @()
12 | FormatsToProcess = @()
13 | NestedModules = @()
14 | FunctionsToExport = @()
15 | CmdletsToExport = @(
16 | 'ConvertTo-NewtonsoftJson'
17 | 'ConvertTo-YamlDotNet'
18 | )
19 | VariablesToExport = @()
20 | AliasesToExport = @()
21 | PrivateData = @{
22 | PSData = @{}
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ALCResolver/src/ALCResolver/ConvertToYamlDotNetCommand.cs:
--------------------------------------------------------------------------------
1 | using ALCResolver.Private;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Management.Automation;
5 |
6 | namespace ALCResolver;
7 |
8 | [Cmdlet(VerbsData.ConvertTo, "YamlDotNet")]
9 | [OutputType(typeof(string))]
10 | public sealed class ConvertToYamlDotNetCommand : PSCmdlet
11 | {
12 | private List