Skip to content

Commit ebbe22f

Browse files
Update SDK to bring unified assembly changes (#31039)
* Update SDK to bring unified assembly changes * Update SDK to pick up Razor pages fix * Fixup test Co-authored-by: Pranav K <[email protected]>
1 parent af600bf commit ebbe22f

File tree

13 files changed

+14
-202
lines changed

13 files changed

+14
-202
lines changed

global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"sdk": {
3-
"version": "6.0.100-preview.3.21160.5"
3+
"version": "6.0.100-preview.3.21168.19"
44
},
55
"tools": {
6-
"dotnet": "6.0.100-preview.3.21160.5",
6+
"dotnet": "6.0.100-preview.3.21168.19",
77
"runtimes": {
88
"dotnet/x64": [
99
"2.1.25",

src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADAuthenticationBuilderExtensions.cs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -198,34 +198,12 @@ void TryAddMapping(AzureADSchemeOptions o)
198198

199199
private static void AddAdditionalMvcApplicationParts(IServiceCollection services)
200200
{
201-
var additionalParts = GetAdditionalParts();
202201
var mvcBuilder = services
203202
.AddMvc()
204203
.ConfigureApplicationPartManager(apm =>
205204
{
206-
foreach (var part in additionalParts)
207-
{
208-
if (!apm.ApplicationParts.Any(ap => HasSameName(ap.Name, part.Name)))
209-
{
210-
apm.ApplicationParts.Add(part);
211-
}
212-
}
213-
214205
apm.FeatureProviders.Add(new AzureADAccountControllerFeatureProvider());
215206
});
216-
217-
bool HasSameName(string left, string right) => string.Equals(left, right, StringComparison.Ordinal);
218-
}
219-
220-
private static IEnumerable<ApplicationPart> GetAdditionalParts()
221-
{
222-
var thisAssembly = typeof(AzureADAuthenticationBuilderExtensions).Assembly;
223-
var relatedAssemblies = RelatedAssemblyAttribute.GetRelatedAssemblies(thisAssembly, throwOnError: true);
224-
225-
foreach (var reference in relatedAssemblies)
226-
{
227-
yield return new CompiledRazorAssemblyPart(reference);
228-
}
229207
}
230208
}
231209
}

src/Azure/AzureAD/Authentication.AzureAD.UI/src/Microsoft.AspNetCore.Authentication.AzureAD.UI.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
77
<PackageTags>aspnetcore;authentication;AzureAD</PackageTags>
88
<GenerateDocumentationFile>true</GenerateDocumentationFile>
9-
<ProvideApplicationPartFactoryAttributeTypeName>Microsoft.AspNetCore.Mvc.ApplicationParts.NullApplicationPartFactory, Microsoft.AspNetCore.Mvc.Core</ProvideApplicationPartFactoryAttributeTypeName>
109
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
1110
</PropertyGroup>
1211

src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
77
<PackageTags>aspnetcore;authentication;AzureADB2C</PackageTags>
88
<GenerateDocumentationFile>true</GenerateDocumentationFile>
9-
<ProvideApplicationPartFactoryAttributeTypeName>Microsoft.AspNetCore.Mvc.ApplicationParts.NullApplicationPartFactory, Microsoft.AspNetCore.Mvc.Core</ProvideApplicationPartFactoryAttributeTypeName>
109
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
1110
</PropertyGroup>
1211

src/Azure/AzureAD/test/FunctionalTests/WebAuthenticationTests.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,8 @@ public WebAuthenticationTests(WebApplicationFactory<Startup> fixture)
3131
public static TheoryData<string> NotAddedEndpoints =>
3232
new TheoryData<string>()
3333
{
34-
"/AzureAD/Account/AccessDenied",
35-
"/AzureAD/Account/Error",
36-
"/AzureAD/Account/SignedOut",
3734
"/AzureAD/Account/SignIn",
3835
"/AzureAD/Account/SignOut",
39-
"/AzureADB2C/Account/AccessDenied",
40-
"/AzureADB2C/Account/Error",
41-
"/AzureADB2C/Account/SignedOut",
4236
"/AzureADB2C/Account/SignIn",
4337
"/AzureADB2C/Account/ResetPassword",
4438
"/AzureADB2C/Account/EditProfile",

src/Identity/UI/src/IdentityBuilderUIExtensions.cs

Lines changed: 1 addition & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static class IdentityBuilderUIExtensions
3434
public static IdentityBuilder AddDefaultUI(this IdentityBuilder builder)
3535
{
3636
builder.AddSignInManager();
37-
AddRelatedParts(builder);
37+
builder.Services.AddMvc();
3838

3939
builder.Services.ConfigureOptions(
4040
typeof(IdentityDefaultUIConfigureOptions<>)
@@ -44,87 +44,6 @@ public static IdentityBuilder AddDefaultUI(this IdentityBuilder builder)
4444
return builder;
4545
}
4646

47-
private static readonly IDictionary<UIFramework, string> _assemblyMap =
48-
new Dictionary<UIFramework, string>()
49-
{
50-
[UIFramework.Bootstrap4] = "Microsoft.AspNetCore.Identity.UI.Views.V4",
51-
};
52-
53-
private static void AddRelatedParts(IdentityBuilder builder)
54-
{
55-
var mvcBuilder = builder.Services
56-
.AddMvc()
57-
.ConfigureApplicationPartManager(partManager =>
58-
{
59-
// We try to resolve the UI framework that was used by looking at the entry assembly.
60-
// When an app runs, the entry assembly will point to the built app. In some rare cases
61-
// (functional testing) the app assembly will be different, and we'll try to locate it through
62-
// the same mechanism that MVC uses today.
63-
// Finally, if for some reason we aren't able to find the assembly, we'll use our default value
64-
// (Bootstrap4)
65-
if (!TryResolveUIFramework(Assembly.GetEntryAssembly(), out var framework) &&
66-
!TryResolveUIFramework(GetApplicationAssembly(builder), out framework))
67-
{
68-
framework = default;
69-
}
70-
71-
var thisAssembly = typeof(IdentityBuilderUIExtensions).Assembly;
72-
var relatedAssemblies = RelatedAssemblyAttribute.GetRelatedAssemblies(thisAssembly, throwOnError: true);
73-
var relatedParts = relatedAssemblies.ToDictionary(
74-
ra => ra,
75-
CompiledRazorAssemblyApplicationPartFactory.GetDefaultApplicationParts);
76-
77-
var selectedFrameworkAssembly = _assemblyMap[framework];
78-
79-
foreach (var kvp in relatedParts)
80-
{
81-
var assemblyName = kvp.Key.GetName().Name;
82-
if (!IsAssemblyForFramework(selectedFrameworkAssembly, assemblyName))
83-
{
84-
RemoveParts(partManager, kvp.Value);
85-
}
86-
else
87-
{
88-
AddParts(partManager, kvp.Value);
89-
}
90-
}
91-
92-
bool IsAssemblyForFramework(string frameworkAssembly, string assemblyName) =>
93-
string.Equals(assemblyName, frameworkAssembly, StringComparison.OrdinalIgnoreCase);
94-
95-
void RemoveParts(
96-
ApplicationPartManager manager,
97-
IEnumerable<ApplicationPart> partsToRemove)
98-
{
99-
for (var i = 0; i < manager.ApplicationParts.Count; i++)
100-
{
101-
var part = manager.ApplicationParts[i];
102-
if (partsToRemove.Any(p => string.Equals(
103-
p.Name,
104-
part.Name,
105-
StringComparison.OrdinalIgnoreCase)))
106-
{
107-
manager.ApplicationParts.Remove(part);
108-
}
109-
}
110-
}
111-
112-
void AddParts(
113-
ApplicationPartManager manager,
114-
IEnumerable<ApplicationPart> partsToAdd)
115-
{
116-
foreach (var part in partsToAdd)
117-
{
118-
if (!manager.ApplicationParts.Any(p => p.GetType() == part.GetType() &&
119-
string.Equals(p.Name, part.Name, StringComparison.OrdinalIgnoreCase)))
120-
{
121-
manager.ApplicationParts.Add(part);
122-
}
123-
}
124-
}
125-
});
126-
}
127-
12847
private static Assembly GetApplicationAssembly(IdentityBuilder builder)
12948
{
13049
// Whis is the same logic that MVC follows to find the application assembly.

src/Identity/UI/src/Microsoft.AspNetCore.Identity.UI.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>
88
<PackageTags>aspnetcore;identity;membership;razorpages</PackageTags>
9-
<ProvideApplicationPartFactoryAttributeTypeName>Microsoft.AspNetCore.Mvc.ApplicationParts.NullApplicationPartFactory, Microsoft.AspNetCore.Mvc.Core</ProvideApplicationPartFactoryAttributeTypeName>
109
<EnableDefaultRazorGenerateItems>false</EnableDefaultRazorGenerateItems>
1110
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
12-
<RazorTargetName>Microsoft.AspNetCore.Identity.UI.Views.V4</RazorTargetName>
1311

1412
<DisableStaticWebAssetsBuildPropsFileGeneration>true</DisableStaticWebAssetsBuildPropsFileGeneration>
1513
<StaticWebAssetsDisableProjectBuildPropsFileGeneration>true</StaticWebAssetsDisableProjectBuildPropsFileGeneration>

src/Identity/UI/src/Properties/AssemblyInfo.ApplicationParts.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/Identity/test/Identity.FunctionalTests/Infrastructure/ServerFactory.cs

Lines changed: 1 addition & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ protected override void ConfigureWebHost(IWebHostBuilder builder)
6262
}
6363

6464
private void UpdateApplicationParts(IWebHostBuilder builder) =>
65-
builder.ConfigureServices(services => AddRelatedParts(services, BootstrapFrameworkVersion));
65+
builder.ConfigureServices(services => services.AddMvc());
6666

6767
private void UpdateStaticAssets(IWebHostBuilder builder)
6868
{
@@ -150,75 +150,5 @@ protected override void Dispose(bool disposing)
150150

151151
base.Dispose(disposing);
152152
}
153-
154-
private static void AddRelatedParts(IServiceCollection services, string framework)
155-
{
156-
var _assemblyMap =
157-
new Dictionary<UIFramework, string>()
158-
{
159-
[UIFramework.Bootstrap4] = "Microsoft.AspNetCore.Identity.UI.Views.V4",
160-
};
161-
162-
var mvcBuilder = services
163-
.AddMvc()
164-
.ConfigureApplicationPartManager(partManager =>
165-
{
166-
var thisAssembly = typeof(IdentityBuilderUIExtensions).Assembly;
167-
var relatedAssemblies = RelatedAssemblyAttribute.GetRelatedAssemblies(thisAssembly, throwOnError: true);
168-
var relatedParts = relatedAssemblies.ToDictionary(
169-
ra => ra,
170-
CompiledRazorAssemblyApplicationPartFactory.GetDefaultApplicationParts);
171-
172-
var selectedFrameworkAssembly = _assemblyMap[UIFramework.Bootstrap4];
173-
174-
foreach (var kvp in relatedParts)
175-
{
176-
var assemblyName = kvp.Key.GetName().Name;
177-
if (!IsAssemblyForFramework(selectedFrameworkAssembly, assemblyName))
178-
{
179-
RemoveParts(partManager, kvp.Value);
180-
}
181-
else
182-
{
183-
AddParts(partManager, kvp.Value);
184-
}
185-
}
186-
187-
bool IsAssemblyForFramework(string frameworkAssembly, string assemblyName) =>
188-
string.Equals(assemblyName, frameworkAssembly, StringComparison.OrdinalIgnoreCase);
189-
190-
void RemoveParts(
191-
ApplicationPartManager manager,
192-
IEnumerable<ApplicationPart> partsToRemove)
193-
{
194-
for (var i = 0; i < manager.ApplicationParts.Count; i++)
195-
{
196-
var part = manager.ApplicationParts[i];
197-
if (partsToRemove.Any(p => string.Equals(
198-
p.Name,
199-
part.Name,
200-
StringComparison.OrdinalIgnoreCase)))
201-
{
202-
manager.ApplicationParts.Remove(part);
203-
}
204-
}
205-
}
206-
207-
void AddParts(
208-
ApplicationPartManager manager,
209-
IEnumerable<ApplicationPart> partsToAdd)
210-
{
211-
foreach (var part in partsToAdd)
212-
{
213-
if (!manager.ApplicationParts.Any(p => p.GetType() == part.GetType() &&
214-
string.Equals(p.Name, part.Name, StringComparison.OrdinalIgnoreCase)))
215-
{
216-
manager.ApplicationParts.Add(part);
217-
}
218-
}
219-
}
220-
});
221-
}
222-
223153
}
224154
}

src/Mvc/test/Mvc.FunctionalTests/RazorPagesNamespaceTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ public async Task Page_DefaultNamespace_IfUnset()
2929
var content = await Client.GetStringAsync("http://localhost/DefaultNamespace");
3030

3131
// Assert
32-
Assert.Equal("AspNetCore", content.Trim());
32+
Assert.Equal("AspNetCoreGeneratedDocument", content.Trim());
3333
}
34-
34+
3535
[Fact]
3636
public async Task Page_ImportedNamespace_UsedFromViewImports()
3737
{
@@ -41,7 +41,7 @@ public async Task Page_ImportedNamespace_UsedFromViewImports()
4141
// Assert
4242
Assert.Equal("CustomNamespace.Nested.Folder", content.Trim());
4343
}
44-
44+
4545
[Fact]
4646
public async Task Page_OverrideNamespace_SetByPage()
4747
{

src/Mvc/test/Mvc.FunctionalTests/RazorPagesTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -932,8 +932,8 @@ public async Task PagePropertiesAreInjected()
932932
// Arrange
933933
var expected =
934934
@"Microsoft.AspNetCore.Mvc.Routing.UrlHelper
935-
Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelper`1[AspNetCore.InjectedPageProperties]
936-
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary`1[AspNetCore.InjectedPageProperties]";
935+
Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelper`1[AspNetCoreGeneratedDocument.InjectedPageProperties]
936+
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary`1[AspNetCoreGeneratedDocument.InjectedPageProperties]";
937937

938938
// Act
939939
var response = await Client.GetStringAsync("InjectedPageProperties");

src/Mvc/test/WebSites/ControllersFromServicesWebSite/Startup.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ public void ConfigureServices(IServiceCollection services)
3232
typeof(ComponentFromServicesViewComponent),
3333
typeof(InServicesTagHelper)));
3434

35-
var relatedAssenbly = RelatedAssemblyAttribute
36-
.GetRelatedAssemblies(GetType().Assembly, throwOnError: true)
37-
.SingleOrDefault();
38-
foreach (var part in CompiledRazorAssemblyApplicationPartFactory.GetDefaultApplicationParts(relatedAssenbly))
35+
foreach (var part in CompiledRazorAssemblyApplicationPartFactory.GetDefaultApplicationParts(Assembly.GetExecutingAssembly()))
3936
{
4037
manager.ApplicationParts.Add(part);
4138
}

src/SignalR/clients/ts/yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+

0 commit comments

Comments
 (0)