Skip to content

Commit cf2bf77

Browse files
works!!!1
1 parent f7e1710 commit cf2bf77

5 files changed

Lines changed: 404 additions & 376 deletions

File tree

implementation-plan.md

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
# Assembly Import Process Optimization Plan
2+
3+
## Overview
4+
5+
This document outlines the plan for optimizing the assembly import process in dbatools.library while maintaining critical platform-specific functionality, particularly for SqlClient.
6+
7+
## Current State Analysis
8+
9+
```mermaid
10+
graph TD
11+
A[Assembly Import Process] --> B[Assembly Lists]
12+
A --> C[Platform Resolution]
13+
A --> D[Assembly Loading]
14+
B --> E[Multiple Lists]
15+
B --> F[Duplicate Entries]
16+
C --> G[Generic Resolution]
17+
C --> H[SqlClient Specific]
18+
D --> I[Multiple Loading Methods]
19+
D --> J[Redundant Error Handling]
20+
```
21+
22+
### Identified Issues
23+
24+
1. Assembly Lists
25+
- Redundant entries between CoreAssemblies and CommonAssemblies
26+
- Duplicate assembly references in load order
27+
- Separate lists for similar purposes
28+
29+
2. Path Resolution
30+
- Similar logic in both redirector and resolver
31+
- Multiple checks for same paths
32+
- Some redundant platform detection
33+
34+
3. Assembly Loading
35+
- Multiple loading mechanisms that could conflict
36+
- Redundant loading attempts
37+
- Inconsistent error handling
38+
39+
## Implementation Plan
40+
41+
### 1. SqlClient-Specific Handling (Priority: High)
42+
43+
Preserve and optimize platform-specific handling for SqlClient:
44+
45+
```mermaid
46+
graph TD
47+
A[SqlClient Handling] --> B[Platform Detection]
48+
A --> C[SNI Loading]
49+
A --> D[Path Resolution]
50+
B --> E[Windows Specific]
51+
B --> F[Unix Specific]
52+
C --> G[Architecture Check]
53+
C --> H[Native Loading]
54+
D --> I[Platform Paths]
55+
D --> J[Version Check]
56+
```
57+
58+
Key Changes:
59+
- Maintain dedicated platform resolution
60+
- Keep architecture-specific SNI loading
61+
- Preserve Windows vs Unix distinctions
62+
- Document platform requirements
63+
64+
Files to Modify:
65+
- assembly-loader.ps1: SNI loading logic
66+
- assembly-resolution.ps1: Platform detection
67+
- assembly-redirector.ps1: SqlClient handling
68+
69+
### 2. Assembly List Optimization (Priority: Medium)
70+
71+
Optimize assembly lists while maintaining platform-specific requirements:
72+
73+
```mermaid
74+
graph TD
75+
A[Assembly Lists] --> B[Core Lists]
76+
A --> C[Platform Lists]
77+
B --> D[Remove Duplicates]
78+
B --> E[Optimize Order]
79+
C --> F[Windows Specific]
80+
C --> G[Unix Specific]
81+
C --> H[DAC Specific]
82+
```
83+
84+
Key Changes:
85+
- Remove truly redundant entries
86+
- Maintain platform-specific lists
87+
- Keep DAC assemblies separate
88+
- Optimize load order
89+
90+
Files to Modify:
91+
- assembly-lists.ps1: List definitions
92+
- assembly-loader.ps1: Load order implementation
93+
94+
### 3. Path Resolution Refinement (Priority: Medium)
95+
96+
Improve path resolution while maintaining platform checks:
97+
98+
```mermaid
99+
graph TD
100+
A[Path Resolution] --> B[Generic Resolution]
101+
A --> C[SqlClient Resolution]
102+
B --> D[Cache Paths]
103+
B --> E[Basic Checks]
104+
C --> F[Platform Checks]
105+
C --> G[Native Paths]
106+
```
107+
108+
Key Changes:
109+
- Separate generic and SqlClient resolution
110+
- Implement path caching
111+
- Maintain platform-specific paths
112+
- Simplify non-critical checks
113+
114+
Files to Modify:
115+
- assembly-resolution.ps1: Path resolution logic
116+
- assembly-redirector.ps1: Platform-specific paths
117+
118+
### 4. Loading Process Improvement (Priority: Medium)
119+
120+
Streamline loading while preserving platform requirements:
121+
122+
```mermaid
123+
graph TD
124+
A[Assembly Loading] --> B[SqlClient Loading]
125+
A --> C[Generic Loading]
126+
B --> D[Platform Specific]
127+
B --> E[Version Check]
128+
C --> F[Consolidated Logic]
129+
C --> G[Error Handling]
130+
```
131+
132+
Key Changes:
133+
- Keep platform-specific SqlClient loading
134+
- Consolidate generic assembly loading
135+
- Improve error handling
136+
- Remove redundant checks
137+
138+
Files to Modify:
139+
- assembly-loader.ps1: Loading logic
140+
- assembly-troubleshoot.ps1: Error handling
141+
142+
## Implementation Order
143+
144+
1. SqlClient-Specific Handling
145+
- Preserve critical platform functionality
146+
- Document requirements
147+
- Update SNI loading
148+
149+
2. Assembly List Optimization
150+
- Remove redundant entries
151+
- Maintain platform lists
152+
- Update load order
153+
154+
3. Path Resolution Refinement
155+
- Implement caching
156+
- Separate resolutions
157+
- Update platform checks
158+
159+
4. Loading Process Improvement
160+
- Consolidate generic loading
161+
- Update error handling
162+
- Remove redundancy
163+
164+
## Testing Recommendations
165+
166+
1. Platform Testing
167+
- Test on Windows (x86, x64, ARM)
168+
- Test on Linux (x64, ARM)
169+
- Test on macOS (x64)
170+
171+
2. Functionality Testing
172+
- SqlClient connectivity
173+
- DAC functionality
174+
- Assembly loading order
175+
- Error handling
176+
177+
3. Performance Testing
178+
- Load time measurements
179+
- Memory usage tracking
180+
- Path resolution speed
181+
182+
## Success Criteria
183+
184+
1. All platform-specific functionality works correctly
185+
2. Reduced code duplication
186+
3. Improved error handling and logging
187+
4. Maintained backward compatibility
188+
5. No regression in functionality
189+
190+
## Next Steps
191+
192+
1. Review and approve plan
193+
2. Create backup of current implementation
194+
3. Begin with SqlClient-specific changes
195+
4. Proceed with remaining optimizations
196+
5. Comprehensive testing
197+
6. Documentation updates

private/assembly-lists.ps1

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,48 @@
33

44
# Core assemblies required across all platforms
55
$script:CoreAssemblies = @(
6-
# System dependencies
6+
# System dependencies - required for basic functionality
77
'System.Memory',
88
'System.Runtime.CompilerServices.Unsafe',
99
'System.Resources.Extensions',
1010
'System.Diagnostics.DiagnosticSource',
1111
'System.Private.CoreLib',
1212

13-
# Azure dependencies
13+
# Azure dependencies - required for authentication and cloud features
1414
'Azure.Core',
1515
'Azure.Identity',
1616
'Microsoft.Identity.Client',
1717
'Microsoft.Identity.Client.Extensions.Msal',
1818
'Microsoft.IdentityModel.Abstractions',
1919

20-
# SQL dependencies
20+
# SQL Server core dependencies - required for basic SQL Server operations
2121
'Microsoft.Data.SqlClient',
22-
'Microsoft.SqlServer.Smo',
2322
'Microsoft.SqlServer.Management.Sdk.Sfc',
2423
'Microsoft.SqlServer.ConnectionInfo',
2524
'Microsoft.SqlServer.SqlEnum',
25+
'Microsoft.SqlServer.Smo',
2626
'Microsoft.SqlServer.Types',
27+
28+
# SQL Server advanced features
2729
'Microsoft.SqlServer.Management.HadrModel',
2830
'Microsoft.SqlServer.Management.HadrData',
2931
'Microsoft.SqlServer.Management.RegisteredServers',
3032
'Microsoft.SqlServer.Management.XEvent',
3133
'Microsoft.SqlServer.Management.XEventDbScoped',
32-
#'Microsoft.SqlServer.Replication',
3334
'Microsoft.SqlServer.Rmo',
34-
'Microsoft.AnalysisServices',
35+
36+
# Analysis Services components
3537
'Microsoft.AnalysisServices.Core',
38+
'Microsoft.AnalysisServices',
3639
'Microsoft.AnalysisServices.Tabular',
3740
'Microsoft.AnalysisServices.Tabular.Json'
3841
)
3942

40-
# DAC-specific assemblies
43+
# DAC-specific assemblies - required for database project and schema management
4144
$script:DacAssemblies = @(
4245
'Microsoft.SqlServer.Dac',
4346
'Microsoft.SqlServer.Dac.Extensions',
4447
'Microsoft.Data.Tools.Schema.Sql'
45-
#'Microsoft.SqlServer.TransactSql.ScriptDom'
4648
)
4749

4850
# Assembly load order to handle dependencies
@@ -78,34 +80,19 @@ $script:AssemblyLoadOrder = @(
7880
'Microsoft.SqlServer.Management.HadrData',
7981
'Microsoft.SqlServer.Management.HadrModel',
8082

81-
# Replication components
82-
#'Microsoft.SqlServer.Replication',
83-
#'Microsoft.SqlServer.Rmo',
84-
85-
# SSIS components
86-
83+
# SSIS components - reserved for future use
8784
# Analysis Services components
8885
'Microsoft.AnalysisServices.Core',
8986
'Microsoft.AnalysisServices',
9087
'Microsoft.AnalysisServices.Tabular',
9188
'Microsoft.AnalysisServices.Tabular.Json',
9289

93-
# DAC components last
94-
#'Microsoft.SqlServer.TransactSql.ScriptDom',
90+
# DAC components - load last due to dependencies
9591
'Microsoft.Data.Tools.Schema.Sql',
9692
'Microsoft.SqlServer.Dac',
9793
'Microsoft.SqlServer.Dac.Extensions'
9894
)
9995

100-
# Common assemblies that are platform-independent
101-
$script:CommonAssemblies = @(
102-
'Microsoft.SqlServer.Management.Sdk.Sfc',
103-
'Microsoft.SqlServer.Smo',
104-
'Microsoft.SqlServer.ConnectionInfo',
105-
'Microsoft.SqlServer.SqlEnum',
106-
'Microsoft.SqlServer.Types'
107-
)
108-
10996
# Define platform-specific paths for assemblies and native dependencies
11097
$script:PlatformAssemblies = @{
11198
'Windows' = @{

0 commit comments

Comments
 (0)