Skip to content

Commit

Permalink
Merge pull request #100 from egvijayanand/working
Browse files Browse the repository at this point in the history
Samples updated for .NET MAUI 9 Stable channel release.
  • Loading branch information
egvijayanand authored Nov 22, 2024
2 parents 8ffcb5e + c5644bd commit f96e55b
Show file tree
Hide file tree
Showing 24 changed files with 191 additions and 14 deletions.
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"sdk": {
"allowPrerelease": true,
"rollForward": "latestMinor",
"version": "8.0.100"
"version": "9.0.100"
}
}
6 changes: 6 additions & 0 deletions src/NET_9/EmbeddedAndroid/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
<MauiVersion>9.*</MauiVersion>
</PropertyGroup>
</Project>
5 changes: 5 additions & 0 deletions src/NET_9/EmbeddedAndroid/EmbeddedAndroid.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmbeddedAndroid", "EmbeddedAndroid.csproj", "{6080BD5C-A536-4175-A64D-78FFC4642A41}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8EC462FD-D22E-90A8-E5CE-7E832BA40C5D}"
ProjectSection(SolutionItems) = preProject
Directory.Packages.props = Directory.Packages.props
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
3 changes: 3 additions & 0 deletions src/NET_9/EmbeddedAndroid/EmbeddedAndroid.slnx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<Solution>
<Folder Name="/Solution Items/">
<File Path="Directory.Packages.props" />
</Folder>
<Project Path="EmbeddedAndroid.csproj">
<Deploy />
</Project>
Expand Down
6 changes: 6 additions & 0 deletions src/NET_9/EmbeddedWindows/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
<MauiVersion>9.*</MauiVersion>
</PropertyGroup>
</Project>
5 changes: 5 additions & 0 deletions src/NET_9/EmbeddedWindows/EmbeddedWindows.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmbeddedWindows", "Embedded
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MauiLib", "MauiLib\MauiLib.csproj", "{E93EB175-0FD3-4BFD-B81A-CDAF33998932}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8EC462FD-D22E-90A8-E5CE-7E832BA40C5D}"
ProjectSection(SolutionItems) = preProject
Directory.Packages.props = Directory.Packages.props
EndProjectSection
EndProject
Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
10 changes: 10 additions & 0 deletions src/NET_9/EmbeddedWindows/EmbeddedWindows.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Solution>
<Folder Name="/Solution Items/">
<File Path="Directory.Packages.props" />
</Folder>
<Project Path="MauiLib\MauiLib.csproj" />
<Project Path="EmbeddedWindows\EmbeddedWindows.csproj">
<Deploy />
<Platform Project="x64" />
</Project>
</Solution>
6 changes: 6 additions & 0 deletions src/NET_9/EmbeddediOS/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
<MauiVersion>9.*</MauiVersion>
</PropertyGroup>
</Project>
5 changes: 5 additions & 0 deletions src/NET_9/EmbeddediOS/EmbeddediOS.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmbeddediOS", "EmbeddediOS.csproj", "{DEB5C69A-CC84-491E-9E3D-72E222628EB2}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8EC462FD-D22E-90A8-E5CE-7E832BA40C5D}"
ProjectSection(SolutionItems) = preProject
Directory.Packages.props = Directory.Packages.props
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
3 changes: 3 additions & 0 deletions src/NET_9/EmbeddediOS/EmbeddediOS.slnx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<Solution>
<Folder Name="/Solution Items/">
<File Path="Directory.Packages.props" />
</Folder>
<Project Path="EmbeddediOS.csproj">
<Deploy />
</Project>
Expand Down
6 changes: 6 additions & 0 deletions src/NET_9/HybridWebViewApp/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
<MauiVersion>9.*</MauiVersion>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/NET_9/HybridWebViewApp/HybridWebViewApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.*-*" Condition="'$(Configuration)' == 'Debug'" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.*" Condition="'$(Configuration)' == 'Debug'" />
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
</ItemGroup>

Expand Down
5 changes: 5 additions & 0 deletions src/NET_9/HybridWebViewApp/HybridWebViewApp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ VisualStudioVersion = 17.0.31611.283
MinimumVisualStudioVersion = 10.0.40219.1
Project("{371A51A3-7E6B-415E-A4CD-ADAC03BCC115}") = "HybridWebViewApp", "HybridWebViewApp.csproj", "{A46627CB-85E6-4A7B-BAA0-A785D0B73BC1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8EC462FD-D22E-90A8-E5CE-7E832BA40C5D}"
ProjectSection(SolutionItems) = preProject
Directory.Packages.props = Directory.Packages.props
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
3 changes: 3 additions & 0 deletions src/NET_9/HybridWebViewApp/HybridWebViewApp.slnx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<Solution>
<Folder Name="/Solution Items/">
<File Path="Directory.Packages.props" />
</Folder>
<Project Path="HybridWebViewApp.csproj">
<Deploy />
</Project>
Expand Down
56 changes: 49 additions & 7 deletions src/NET_9/HybridWebViewApp/Resources/Raw/wwwroot/scripts/hwv.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
window.HybridWebView = {
"Init": function () {
"Init": function Init() {
function DispatchHybridWebViewMessage(message) {
const event = new CustomEvent("HybridWebViewMessageReceived", { detail: { message: message } });
window.dispatchEvent(event);
Expand Down Expand Up @@ -27,11 +27,53 @@
}
},

"SendRawMessage": function (message) {
window.HybridWebView.__SendMessageInternal('RawMessage', message);
"SendRawMessage": function SendRawMessage(message) {
window.HybridWebView.__SendMessageInternal('__RawMessage', message);
},

"__SendMessageInternal": function (type, message) {
"InvokeDotNet": async function InvokeDotNetAsync(methodName, paramValues) {
const body = {
MethodName: methodName
};

if (typeof paramValues !== 'undefined') {
if (!Array.isArray(paramValues)) {
paramValues = [paramValues];
}

for (var i = 0; i < paramValues.length; i++) {
paramValues[i] = JSON.stringify(paramValues[i]);
}

if (paramValues.length > 0) {
body.ParamValues = paramValues;
}
}

const message = JSON.stringify(body);

var requestUrl = `${window.location.origin}/__hwvInvokeDotNet?data=${encodeURIComponent(message)}`;

const rawResponse = await fetch(requestUrl, {
method: 'GET',
headers: {
'Accept': 'application/json'
}
});
const response = await rawResponse.json();

if (response) {
if (response.IsJson) {
return JSON.parse(response.Result);
}

return response.Result;
}

return null;
},

"__SendMessageInternal": function __SendMessageInternal(type, message) {

const messageToSend = type + '|' + message;

Expand All @@ -49,7 +91,7 @@
}
},

"InvokeMethod": function (taskId, methodName, args) {
"__InvokeJavaScript": function __InvokeJavaScript(taskId, methodName, args) {
if (methodName[Symbol.toStringTag] === 'AsyncFunction') {
// For async methods, we need to call the method and then trigger the callback when it's done
const asyncPromise = methodName(...args);
Expand All @@ -65,13 +107,13 @@
}
},

"__TriggerAsyncCallback": function (taskId, result) {
"__TriggerAsyncCallback": function __TriggerAsyncCallback(taskId, result) {
// Make sure the result is a string
if (result && typeof (result) !== 'string') {
result = JSON.stringify(result);
}

window.HybridWebView.__SendMessageInternal('InvokeMethodCompleted', taskId + '|' + result);
window.HybridWebView.__SendMessageInternal('__InvokeJavaScriptCompleted', taskId + '|' + result);
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/NET_9/MapsApp/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
<MauiVersion>9.*</MauiVersion>
</PropertyGroup>
</Project>
5 changes: 5 additions & 0 deletions src/NET_9/MapsApp/MapsApp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ VisualStudioVersion = 17.5.33103.201
MinimumVisualStudioVersion = 10.0.40219.1
Project("{CC39106E-4594-4901-AEFB-51DE890E7E34}") = "MapsApp", "MapsApp.csproj", "{89D6D593-C99A-4072-8777-D8A241E1BFDD}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8EC462FD-D22E-90A8-E5CE-7E832BA40C5D}"
ProjectSection(SolutionItems) = preProject
Directory.Packages.props = Directory.Packages.props
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|arm64 = Debug|arm64
Expand Down
13 changes: 13 additions & 0 deletions src/NET_9/MapsApp/MapsApp.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Solution>
<Folder Name="/Solution Items/">
<File Path="Directory.Packages.props" />
</Folder>
<Project Path="MapsApp.csproj">
<Deploy />
<Platform Project="x64" />
</Project>
<Properties Name="Visual Studio">
<!-- Support is provisionally available on Visual Studio 17.10 and later versions. -->
<Property Name="OpenWith" Value="17" />
</Properties>
</Solution>
6 changes: 6 additions & 0 deletions src/NET_9/WinUIBlazor/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
<MauiVersion>9.*</MauiVersion>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.*-*" Condition="'$(Configuration)' == 'Debug'" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.*" Condition="'$(Configuration)' == 'Debug'" />
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="VijayAnand.MauiBlazor.Markup" Version="4.*-preview*" />
<PackageReference Include="VijayAnand.MauiBlazor.Markup" Version="4.*" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="9.*-*" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="9.*" />
</ItemGroup>
</Project>
39 changes: 39 additions & 0 deletions src/NET_9/WinUIBlazor/WinUIBlazor.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinUIBlazor", "WinUIBlazor\WinUIBlazor.csproj", "{B4FE125E-4AFF-44EB-A3B7-DC1793D7CBA6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinUIBlazor.MauiLib", "WinUIBlazor.MauiLib\WinUIBlazor.MauiLib.csproj", "{71F838CD-A4C9-48E4-ABA9-716FB160CBEB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinUIBlazor.RazorLib", "WinUIBlazor.RazorLib\WinUIBlazor.RazorLib.csproj", "{F427596A-19AA-4AC4-9F24-BCCF206EBBF0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8EC462FD-D22E-90A8-E5CE-7E832BA40C5D}"
ProjectSection(SolutionItems) = preProject
Directory.Packages.props = Directory.Packages.props
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F427596A-19AA-4AC4-9F24-BCCF206EBBF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F427596A-19AA-4AC4-9F24-BCCF206EBBF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F427596A-19AA-4AC4-9F24-BCCF206EBBF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F427596A-19AA-4AC4-9F24-BCCF206EBBF0}.Release|Any CPU.Build.0 = Release|Any CPU
{71F838CD-A4C9-48E4-ABA9-716FB160CBEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{71F838CD-A4C9-48E4-ABA9-716FB160CBEB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{71F838CD-A4C9-48E4-ABA9-716FB160CBEB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{71F838CD-A4C9-48E4-ABA9-716FB160CBEB}.Release|Any CPU.Build.0 = Release|Any CPU
{B4FE125E-4AFF-44EB-A3B7-DC1793D7CBA6}.Debug|Any CPU.ActiveCfg = Debug|x86
{B4FE125E-4AFF-44EB-A3B7-DC1793D7CBA6}.Debug|Any CPU.Build.0 = Debug|x86
{B4FE125E-4AFF-44EB-A3B7-DC1793D7CBA6}.Release|Any CPU.ActiveCfg = Release|x86
{B4FE125E-4AFF-44EB-A3B7-DC1793D7CBA6}.Release|Any CPU.Build.0 = Release|x86
EndGlobalSection
EndGlobal
5 changes: 4 additions & 1 deletion src/NET_9/WinUIBlazor/WinUIBlazor.slnx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<Solution>
<Folder Name="/Solution Items/">
<File Path="Directory.Packages.props" />
</Folder>
<Project Path="WinUIBlazor\WinUIBlazor.csproj">
<Deploy />
<Platform Project="x64" />
Expand All @@ -9,4 +12,4 @@
<!-- Support is provisionally available on Visual Studio 17.10 and later versions. -->
<Property Name="OpenWith" Value="Visual Studio Version 17" />
</Properties>
</Solution>
</Solution>
2 changes: 1 addition & 1 deletion src/NET_9/global.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"sdk": {
"allowPrerelease": true,
"rollForward": "latestMinor",
"version": "9.0.100-preview.1.24101.2"
"version": "9.0.100"
}
}

0 comments on commit f96e55b

Please sign in to comment.