Skip to content

Commit

Permalink
6.0.1 cherry picks (#1730)
Browse files Browse the repository at this point in the history
* Add models from other projects [Regression] (#1718)

* finding missing workspace files

* using models from different projects enabled.

* cleaning up more.

* updated Versions.props

* not adding/forcing Account.Logout.cshtml if blazor project already adds it. (#1721)

* Adding #nullable disable to scaffolding templates (#1723)

* checking for nullable msbuild property and adding #nullable disable to tempaltes

* added #nulalble disable logic for NewLocalDbContext

* updated macOS image

* fixed mistake with azure images

* updating Versions.MSIdentity.props to 1.0.1

* Enable Microsoft Graph option for Blazor Server (#1719)

Enable Microsoft Graph option for Blazor Server, add .razor modification functionality

Co-authored-by: zahalzel <75647613+zahalzel@users.noreply.github.com>
  • Loading branch information
deepchoudhery and zahalzel committed Mar 24, 2022
1 parent abb901a commit 4e8a252
Show file tree
Hide file tree
Showing 8 changed files with 825 additions and 692 deletions.
81 changes: 40 additions & 41 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,47 +108,46 @@ stages:
$(_ValidateSdkArgs)
displayName: Windows Build / Publish

- ${{ if or(eq(variables['System.TeamProject'], 'public'), in(variables['Build.Reason'], 'PullRequest')) }}:
- job: OSX
pool:
vmImage: macOS-11
strategy:
matrix:
release_configuration:
_BuildConfig: Release
${{ if eq(variables['System.TeamProject'], 'public') }}:
debug_configuration:
_BuildConfig: Debug
steps:
- checkout: self
clean: true
- script: eng/common/cibuild.sh
--configuration $(_BuildConfig)
--prepareMachine
name: Build
displayName: Build
condition: succeeded()

- job: Linux
pool:
vmImage: ubuntu-18.04
container: LinuxContainer
strategy:
matrix:
release_configuration:
_BuildConfig: Release
${{ if eq(variables['System.TeamProject'], 'public') }}:
debug_configuration:
_BuildConfig: Debug
steps:
- checkout: self
clean: true
- script: eng/common/cibuild.sh
--configuration $(_BuildConfig)
--prepareMachine
name: Build
displayName: Build
condition: succeeded()
- job: OSX
pool:
vmImage: macOS-11
strategy:
matrix:
release_configuration:
_BuildConfig: Release
${{ if eq(variables['System.TeamProject'], 'public') }}:
debug_configuration:
_BuildConfig: Debug
steps:
- checkout: self
clean: true
- script: eng/common/cibuild.sh
--configuration $(_BuildConfig)
--prepareMachine
name: Build
displayName: Build
condition: succeeded()

- job: Linux
pool:
vmImage: ubuntu-18.04
container: LinuxContainer
strategy:
matrix:
release_configuration:
_BuildConfig: Release
${{ if eq(variables['System.TeamProject'], 'public') }}:
debug_configuration:
_BuildConfig: Debug
steps:
- checkout: self
clean: true
- script: eng/common/cibuild.sh
--configuration $(_BuildConfig)
--prepareMachine
name: Build
displayName: Build
condition: succeeded()

- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
- template: eng\common\templates\post-build\post-build.yml
Expand Down
5 changes: 2 additions & 3 deletions eng/Versions.MSIdentity.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
<UsingToolNetFrameworkReferenceAssemblies>true</UsingToolNetFrameworkReferenceAssemblies>
</PropertyGroup>
<PropertyGroup>
<VersionPrefix>2.0.0</VersionPrefix>
<PreReleaseVersionLabel>preview</PreReleaseVersionLabel>
<PreReleaseVersionIteration>1</PreReleaseVersionIteration>
<VersionPrefix>1.0.1</VersionPrefix>
<PreReleaseVersionLabel>rtm</PreReleaseVersionLabel>
<IsServicingBuild Condition="'$(PreReleaseVersionLabel)' == 'servicing'">true</IsServicingBuild>
<!--
When StabilizePackageVersion is set to 'true', this branch will produce stable outputs for 'Shipping' packages
Expand Down
6 changes: 2 additions & 4 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
<!-- Ref packages -->
</PropertyGroup>
<PropertyGroup>
<VersionPrefix>7.0.0</VersionPrefix>
<PreReleaseVersionLabel>preview</PreReleaseVersionLabel>
<PreReleaseVersionIteration>2</PreReleaseVersionIteration>
<IncludeSourceRevisionInInformationalVersion>False</IncludeSourceRevisionInInformationalVersion>
<VersionPrefix>6.0.1</VersionPrefix>
<PreReleaseVersionLabel>rtm</PreReleaseVersionLabel>
<IsServicingBuild Condition="'$(PreReleaseVersionLabel)' == 'servicing'">true</IsServicingBuild>
<!--
When StabilizePackageVersion is set to 'true', this branch will produce stable outputs for 'Shipping' packages
Expand Down
2 changes: 1 addition & 1 deletion scripts/install-aspnet-codegenerator.cmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set VERSION=7.0.0-dev
set VERSION=6.0.1
set DEFAULT_NUPKG_PATH=%userprofile%\.nuget\packages
set SRC_DIR=%cd%
set NUPKG=artifacts/packages/Debug/Shipping/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
@page "/showprofile"

@using Microsoft.Identity.Web
@using Microsoft.Graph
@inject Microsoft.Graph.GraphServiceClient GraphServiceClient
@inject MicrosoftIdentityConsentAndConditionalAccessHandler ConsentHandler

<h1>Me</h1>

<p>This component demonstrates fetching data from a service.</p>

@if (user == null)
{
<p><em>Loading...</em></p>
}
else
{
<table class="table table-striped table-condensed" style="font-family: monospace">
<tr>
<th>Property</th>
<th>Value</th>
</tr>
<tr>
<td>Name</td>
<td>@user.DisplayName</td>
</tr>
<tr>
<td>Photo</td>
<td>
@{
if (photo != null)
{
<img style="margin: 5px 0; width: 150px" src="data:image/jpeg;base64, @photo" />
}
else
{
<h3>NO PHOTO</h3>
<p>Check user profile in Azure Active Directory to add a photo.</p>
}
}
</td>
</tr>
</table>
}

@code {
User user;
string photo;

protected override async Task OnInitializedAsync()
{
try
{
user = await GraphServiceClient.Me.Request().GetAsync();
photo = await GetPhoto();
}
catch (Exception ex)
{
ConsentHandler.HandleException(ex);
}
}

protected async Task<string> GetPhoto()
{
string photo;

try
{
using (var photoStream = await GraphServiceClient.Me.Photo.Content.Request().GetAsync())
{
byte[] photoByte = ((System.IO.MemoryStream)photoStream).ToArray();
photo = Convert.ToBase64String(photoByte);
this.StateHasChanged();
}

}
catch (Exception)
{
photo = null;
}
return photo;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,59 @@ private PropertyInfo? CodeModifierConfigPropertyInfo

return _codeModifierConfigPropertyInfo;
}
else if (fileName.EndsWith(".cs"))
{
await ModifyCsFile(fileName, file, project, options);
}
else if (fileName.EndsWith(".cshtml"))
{
await ModifyCshtmlFile(fileName, file, project, options);
}
else if (fileName.EndsWith(".razor"))
{
await ModifyRazorFile(fileName, file, project, options);
}
}

/// <summary>
/// Determines if specified file exists, and if not then creates the
/// file based on template stored in AppProvisioningTool.Properties
/// and adds file to the project
/// </summary>
/// <param name="file"></param>
/// <exception cref="FormatException"></exception>
private void AddFile(CodeFile file)
{
var filePath = Path.Combine(_toolOptions.ProjectPath, file.AddFilePath);
if (File.Exists(filePath))
{
return; // File exists, don't need to create
}

// Resource names for addFiles prefixed with "add" and contain '_' in place of '.'
// fileName: "ShowProfile.razor" -> resourceName: "add_ShowProfile_razor"
var resourceName = file.FileName.Replace('.', '_');
var propertyInfo = AppProvisioningTool.Properties.Where(
p => p.Name.StartsWith("add") && p.Name.EndsWith(resourceName)).FirstOrDefault();

if (propertyInfo is null)
{
return;
}

byte[] content = (propertyInfo.GetValue(null) as byte[])!;
string codeFileString = Encoding.UTF8.GetString(content);
if (string.IsNullOrEmpty(codeFileString))
{
throw new FormatException($"Resource file { propertyInfo.Name } could not be parsed. ");
}

var fileDir = Path.GetDirectoryName(filePath);
if (!string.IsNullOrEmpty(fileDir))
{
Directory.CreateDirectory(fileDir);
File.WriteAllText(filePath, codeFileString);
}
}

private CodeModifierConfig? ReadCodeModifierConfigFromFileContent(byte[] fileContent)
Expand Down Expand Up @@ -286,7 +339,6 @@ node is ClassDeclarationSyntax cds &&
modifiedClassDeclarationSyntax = ModifyMethods(modifiedClassDeclarationSyntax, documentBuilder, file.Methods, options);

//add code snippets/changes.

//replace class node with all the updates.
#pragma warning disable CS8631 // The type cannot be used as type parameter in the generic type or method. Nullability of type argument doesn't match constraint type.
root = root.ReplaceNode(classNode, modifiedClassDeclarationSyntax);
Expand Down
Loading

0 comments on commit 4e8a252

Please sign in to comment.