Skip to content

Commit 271f693

Browse files
DanielCarminghamgalvesribeiro
authored andcommitted
Update to Blazor 3.0.0-preview4 (#26)
* Update to Blazor 0.9 * Add SDK installer tasks to pipelines for .Net Core SDK 3.0.100-preview3-010431. * Changes for 3.0.0-preview4 * Remove .bak file * Remove unnecessary package references * Remove global.json * Update to match blazorlib template - updated SDK, package refs, etc * Revert "Remove global.json" This reverts commit 6c1da40. * Rename runtime to _runtime and add this. where missing. * Remove myget.org package sources. * Move JSRuntime to constructor of HubConnectionBuilder * Register/inject HubConnectionBuilder instead of constructing it explicitly so it can obtain its own IJSRuntime reference via DI. * Revert "Remove .bak file" This reverts commit 54b49df. * Rename .editorconfig.bak to .editorconfig
1 parent c15eb63 commit 271f693

22 files changed

+132
-98
lines changed

.vsts-ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ variables:
55

66
steps:
77

8+
- task: DotNetCoreInstaller@0
9+
inputs:
10+
packageType: 'sdk'
11+
version: '3.0.100-preview4-011223'
12+
813
- task: DotNetCoreCLI@2
914
inputs:
1015
command: 'restore'

.vsts-release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ variables:
55

66
steps:
77

8+
- task: DotNetCoreInstaller@0
9+
inputs:
10+
packageType: 'sdk'
11+
version: '3.0.100-preview4-011223'
12+
813
- task: DotNetCoreCLI@2
914
inputs:
1015
command: 'restore'

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "2.1.302"
3+
"version": "3.0.100-preview4-011223"
44
}
55
}

src/Blazor.Extensions.SignalR.JS/Blazor.Extensions.SignalR.JS.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
44
<OutputType>Library</OutputType>
@@ -14,7 +14,6 @@
1414
</PropertyGroup>
1515

1616
<ItemGroup>
17-
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="0.7.0" />
1817
<WebpackInputs Include="**\*.ts" Exclude="dist\**;node_modules\**" />
1918
</ItemGroup>
2019

src/Blazor.Extensions.SignalR.JS/package-lock.json

Lines changed: 21 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Blazor.Extensions.SignalR/Blazor.Extensions.SignalR.csproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
44
<Title>Blazor Extensions SignalR</Title>
55
<Description>SignalR Core support for ASP.NET Core Blazor.</Description>
66
</PropertyGroup>
77

88
<PropertyGroup>
9-
<OutputType>Library</OutputType>
9+
<TargetFramework>netstandard2.0</TargetFramework>
10+
<IsPackable>true</IsPackable>
11+
<LangVersion>7.3</LangVersion>
12+
<RazorLangVersion>3.0</RazorLangVersion>
13+
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
1014
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);IncludeP2POutput</TargetsForTfmSpecificBuildOutput>
1115
</PropertyGroup>
1216

1317
<ItemGroup>
14-
<PackageReference Include="Microsoft.AspNetCore.Blazor.Browser" Version="0.7.0" />
18+
<PackageReference Include="Microsoft.AspNetCore.Components.Browser" Version="3.0.0-preview4-19216-03" />
1519
</ItemGroup>
1620

1721
<ItemGroup>

src/Blazor.Extensions.SignalR/HubConnection.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,21 @@ public class HubConnection : IDisposable
2323
private Dictionary<string, Dictionary<string, HubMethodCallback>> _callbacks = new Dictionary<string, Dictionary<string, HubMethodCallback>>();
2424

2525
private HubCloseCallback _closeCallback;
26+
private IJSRuntime _runtime;
2627

27-
public HubConnection(HttpConnectionOptions options)
28+
public HubConnection(IJSRuntime runtime, HttpConnectionOptions options)
2829
{
30+
this._runtime = runtime;
2931
this.Options = options;
3032
this.InternalConnectionId = Guid.NewGuid().ToString();
31-
JSRuntime.Current.InvokeSync<object>(CREATE_CONNECTION_METHOD,
33+
runtime.InvokeSync<object>(CREATE_CONNECTION_METHOD,
3234
this.InternalConnectionId,
3335
new DotNetObjectRef(this.Options));
3436
}
3537

3638

37-
public Task StartAsync() => JSRuntime.Current.InvokeAsync<object>(START_CONNECTION_METHOD, this.InternalConnectionId);
38-
public Task StopAsync() => JSRuntime.Current.InvokeAsync<object>(STOP_CONNECTION_METHOD, this.InternalConnectionId);
39+
public Task StartAsync() => this._runtime.InvokeAsync<object>(START_CONNECTION_METHOD, this.InternalConnectionId);
40+
public Task StopAsync() => this._runtime.InvokeAsync<object>(STOP_CONNECTION_METHOD, this.InternalConnectionId);
3941

4042
public IDisposable On<TResult1>(string methodName, Func<TResult1, Task> handler)
4143
=> On<TResult1, object, object, object, object, object, object, object, object, object>(methodName,
@@ -163,7 +165,7 @@ internal void RegisterHandle(string methodName, HubMethodCallback callback)
163165
};
164166
}
165167

166-
JSRuntime.Current.InvokeSync<object>(ON_METHOD, this.InternalConnectionId, new DotNetObjectRef(callback));
168+
this._runtime.InvokeSync<object>(ON_METHOD, this.InternalConnectionId, new DotNetObjectRef(callback));
167169
}
168170

169171
internal void RemoveHandle(string methodName, string callbackId)
@@ -172,7 +174,7 @@ internal void RemoveHandle(string methodName, string callbackId)
172174
{
173175
if (callbacks.TryGetValue(callbackId, out var callback))
174176
{
175-
JSRuntime.Current.InvokeSync<object>(OFF_METHOD, this.InternalConnectionId, methodName, callbackId);
177+
this._runtime.InvokeSync<object>(OFF_METHOD, this.InternalConnectionId, methodName, callbackId);
176178
//HubConnectionManager.Off(this.InternalConnectionId, handle.Item1);
177179
callbacks.Remove(callbackId);
178180

@@ -187,17 +189,17 @@ internal void RemoveHandle(string methodName, string callbackId)
187189
public void OnClose(Func<Exception, Task> callback)
188190
{
189191
this._closeCallback = new HubCloseCallback(callback);
190-
JSRuntime.Current.InvokeSync<object>(ON_CLOSE_METHOD,
192+
this._runtime.InvokeSync<object>(ON_CLOSE_METHOD,
191193
this.InternalConnectionId,
192194
new DotNetObjectRef(this._closeCallback));
193195
}
194196

195197
public Task InvokeAsync(string methodName, params object[] args) =>
196-
JSRuntime.Current.InvokeAsync<object>(INVOKE_ASYNC_METHOD, this.InternalConnectionId, methodName, args);
198+
this._runtime.InvokeAsync<object>(INVOKE_ASYNC_METHOD, this.InternalConnectionId, methodName, args);
197199

198200
public Task<TResult> InvokeAsync<TResult>(string methodName, params object[] args) =>
199-
JSRuntime.Current.InvokeAsync<TResult>(INVOKE_WITH_RESULT_ASYNC_METHOD, this.InternalConnectionId, methodName, args);
201+
this._runtime.InvokeAsync<TResult>(INVOKE_WITH_RESULT_ASYNC_METHOD, this.InternalConnectionId, methodName, args);
200202

201-
public void Dispose() => JSRuntime.Current.InvokeSync<object>(REMOVE_CONNECTION_METHOD, this.InternalConnectionId);
203+
public void Dispose() => this._runtime.InvokeSync<object>(REMOVE_CONNECTION_METHOD, this.InternalConnectionId);
202204
}
203205
}

src/Blazor.Extensions.SignalR/HubConnectionBuilder.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
using System;
2+
using Microsoft.JSInterop;
23

34
namespace Blazor.Extensions
45
{
56
public class HubConnectionBuilder
67
{
78
private bool _hubConnectionBuilt;
89

10+
private IJSRuntime _runtime;
11+
912
internal HttpConnectionOptions Options { get; set; } = new HttpConnectionOptions();
1013

14+
public HubConnectionBuilder(IJSRuntime runtime)
15+
{
16+
this._runtime = runtime;
17+
}
18+
1119
/// <summary>
1220
/// Build a SignalR <see cref="HubConnection"/>
1321
/// This method can only be called once.
@@ -23,7 +31,7 @@ public HubConnection Build()
2331

2432
this._hubConnectionBuilt = true;
2533

26-
return new HubConnection(this.Options);
34+
return new HubConnection(this._runtime, this.Options);
2735
}
2836
}
2937

test/Blazor.Extensions.SignalR.Test.Client/App.cshtml

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<Router AppAssembly="typeof(Program).Assembly" />

0 commit comments

Comments
 (0)