@@ -29,42 +29,110 @@ protected override string GetSourceProjectFileContent()
2929 PackageTags = AzureClientPlugin . Instance . Configuration . RootNamespace ,
3030 GenerateDocumentationFile = true ,
3131 } ;
32- foreach ( var packages in _unbrandedDependencyPackages )
32+
33+ foreach ( var packages in _azureDependencyPackages )
3334 {
3435 builder . PackageReferences . Add ( packages ) ;
3536 }
3637
38+ int pathSegmentCount = GetPathSegmentCount ( ) ;
3739 if ( AzureClientPlugin . Instance . InputLibrary . InputNamespace . Auth . ApiKey is not null )
3840 {
39- ReadOnlySpan < char > text = AzureClientPlugin . Instance . Configuration . OutputDirectory . AsSpan ( ) ;
40- // we are either a spector project in the eng folder or a real sdk in the sdk folder
41- int beginning = text . IndexOf ( "eng" ) ;
42- if ( beginning == - 1 )
43- {
44- beginning = text . IndexOf ( "sdk" ) ;
45- }
46- text = text . Slice ( beginning ) ;
47- // starting with 2 to include eng at the beginning and src at the end
48- int pathSegmentCount = 2 + text . Count ( '/' ) ;
49- // count both path separators to normalize
50- pathSegmentCount += text . Count ( '\\ ' ) ;
5141 builder . CompileIncludes . Add ( new CSharpProjectWriter . CSProjCompileInclude ( GetCompileInclude ( "AzureKeyCredentialPolicy.cs" , pathSegmentCount ) , "Shared/Core" ) ) ;
42+ }
43+
44+ TraverseInput ( out bool hasOperation , out bool hasLongRunningOperation ) ;
45+ if ( hasOperation )
46+ {
5247 builder . CompileIncludes . Add ( new CSharpProjectWriter . CSProjCompileInclude ( GetCompileInclude ( "RawRequestUriBuilder.cs" , pathSegmentCount ) , "Shared/Core" ) ) ;
5348 }
5449
50+ if ( hasLongRunningOperation )
51+ {
52+ foreach ( var file in _lroSharedFiles )
53+ {
54+ builder . CompileIncludes . Add ( new CSharpProjectWriter . CSProjCompileInclude ( GetCompileInclude ( file , pathSegmentCount ) , "Shared/Core" ) ) ;
55+ }
56+ }
57+
5558 return builder . Write ( ) ;
5659 }
5760
61+ private static readonly IReadOnlyList < string > _lroSharedFiles =
62+ [
63+ "AppContextSwitchHelper.cs" ,
64+ "AsyncLockWithValue.cs" ,
65+ "FixedDelayWithNoJitterStrategy.cs" ,
66+ "ClientDiagnostics.cs" ,
67+ "DiagnosticScopeFactory.cs" ,
68+ "DiagnosticScope.cs" ,
69+ "HttpMessageSanitizer.cs" ,
70+ "IOperationSource.cs" ,
71+ "NextLinkOperationImplementation.cs" ,
72+ "OperationFinalStateVia.cs" ,
73+ "OperationInternal.cs" ,
74+ "OperationInternalBase.cs" ,
75+ "OperationInternalOfT.cs" ,
76+ "OperationPoller.cs" ,
77+ "SequentialDelayStrategy.cs" ,
78+ "TaskExtensions.cs" ,
79+ "TrimmingAttribute.cs" ,
80+ "VoidValue.cs"
81+ ] ;
82+
83+ private static void TraverseInput ( out bool hasOperation , out bool hasLongRunningOperation )
84+ {
85+ hasOperation = false ;
86+ hasLongRunningOperation = false ;
87+ foreach ( var inputClient in AzureClientPlugin . Instance . InputLibrary . InputNamespace . Clients )
88+ {
89+ foreach ( var operation in inputClient . Operations )
90+ {
91+ hasOperation = true ;
92+ if ( operation . LongRunning != null )
93+ {
94+ hasLongRunningOperation = true ;
95+ return ;
96+ }
97+ }
98+ }
99+ }
100+
101+ private static int GetPathSegmentCount ( )
102+ {
103+ ReadOnlySpan < char > text = AzureClientPlugin . Instance . Configuration . OutputDirectory . AsSpan ( ) ;
104+ // we are either a spector project in the eng folder or a real sdk in the sdk folder
105+ int beginning = text . IndexOf ( "eng" ) ;
106+ if ( beginning == - 1 )
107+ {
108+ beginning = text . IndexOf ( "sdk" ) ;
109+ }
110+ text = text . Slice ( beginning ) ;
111+ // starting with 2 to include eng at the beginning and src at the end
112+ int pathSegmentCount = 2 + text . Count ( '/' ) ;
113+ // count both path separators to normalize
114+ pathSegmentCount += text . Count ( '\\ ' ) ;
115+ return pathSegmentCount ;
116+ }
117+
58118 private string GetCompileInclude ( string fileName , int pathSegmentCount )
59119 {
60120 return $ "{ MSBuildThisFileDirectory } { string . Concat ( Enumerable . Repeat ( ParentDirectory , pathSegmentCount ) ) } { RelativeCoreSegment } { fileName } ";
61121 }
62122
63- private static readonly IReadOnlyList < CSharpProjectWriter . CSProjDependencyPackage > _unbrandedDependencyPackages =
64- [
65- new ( "Azure.Core" ) ,
66- new ( "System.Text.Json" )
67- ] ;
123+ private static readonly IReadOnlyList < CSharpProjectWriter . CSProjDependencyPackage > _azureDependencyPackages =
124+ AzureClientPlugin . Instance . IsAzureArm . Value == true
125+ ? [
126+ new ( "Azure.Core" ) ,
127+ new ( "Azure.ResourceManager" ) ,
128+ new ( "System.ClientModel" ) ,
129+ new ( "System.Text.Json" )
130+ ]
131+ : [
132+ new ( "Azure.Core" ) ,
133+ new ( "System.ClientModel" ) ,
134+ new ( "System.Text.Json" )
135+ ] ;
68136
69137 /// <inheritdoc/>
70138 protected override string GetSolutionFileContent ( )
0 commit comments