Skip to content

Commit

Permalink
Merge branch 'upgrade-to-net8' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
rbergen committed Dec 6, 2023
2 parents 6b57f9a + 3010460 commit ec95dc7
Show file tree
Hide file tree
Showing 38 changed files with 204 additions and 234 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Azure SWA production CD

on:
workflow_dispatch:
push:
branches:
- production
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Azure SWA staging CD

on:
workflow_dispatch:
push:
branches:
- staging
Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
name: Plain .NET build

on:
push:
pull_request:
branches:
- staging
- production
on: [workflow_dispatch, push, pull_request]

jobs:
build:
Expand All @@ -17,7 +12,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- name: Install wasm-tools for Blazor AOT compilation
run: dotnet workload install wasm-tools
- name: Restore dependencies
Expand Down
16 changes: 6 additions & 10 deletions src/R136.BuildTool/R136.BuildTool.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Nullable>enable</Nullable>
</PropertyGroup>

<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\SolutionInfo.cs" Link="SolutionInfo.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\R136.Entities\R136.Entities.csproj" />
</ItemGroup>

</Project>
</Project>
22 changes: 11 additions & 11 deletions src/R136.Core/Engine.FieldsTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ public class Snapshot : Item.ISnapshotContainer, Animate.ISnapshotContainer, ISn
public Animate.Snapshot[]? Animates { get; set; }
public Player.Snapshot? Player { get; set; }

public void AddBytes(List<byte> bytes)
public void AddBytesTo(List<byte> bytes)
{
HasTreeBurned.AddByte(bytes);
IsAnimateTriggered.AddByte(bytes);
DoNext.AddByte(bytes);

Configuration.AddSnapshotBytes(bytes);
LocationCommandProcessor.AddSnapshotBytes(bytes);
Items.AddSnapshotsBytes(bytes);
Flashlight.AddSnapshotBytes(bytes);
Animates.AddSnapshotsBytes(bytes);
Player.AddSnapshotBytes(bytes);
HasTreeBurned.AddByteTo(bytes);
IsAnimateTriggered.AddByteTo(bytes);
DoNext.AddByteTo(bytes);

Configuration.AddSnapshotBytesTo(bytes);
LocationCommandProcessor.AddSnapshotBytesTo(bytes);
Items.AddSnapshotsBytesTo(bytes);
Flashlight.AddSnapshotBytesTo(bytes);
Animates.AddSnapshotsBytesTo(bytes);
Player.AddSnapshotBytesTo(bytes);
}

public int? LoadBytes(ReadOnlyMemory<byte> bytes)
Expand Down
32 changes: 16 additions & 16 deletions src/R136.Core/Engine.PrivateMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private bool ValidateStep(NextStep step)
return DoNext == step;
}

private void AddRoomInformation(List<string> texts, Room playerRoom)
private void AddRoomInformation(List<string?> texts, Room playerRoom)
{
texts.AddRangeIfNotNull(GetTexts(TextID.YouAreAt, "room", playerRoom.Name));

Expand Down Expand Up @@ -173,25 +173,25 @@ private void AddRoomInformation(List<string> texts, Room playerRoom)
var itemLineTextList = itemLineTexts.ToArray();

if (items.Length == 1)
return itemLineTextList.Get(ItemLineText.SingleItem).Replace("{item}", items[0].Name);
return itemLineTextList?.Get(ItemLineText.SingleItem)?.Replace("{item}", items[0].Name);

string itemSection = itemLineTextList.Get(ItemLineText.LastTwoItems).ReplacePlaceholders(new Dictionary<string, object>
string itemSection = itemLineTextList.Get(ItemLineText.LastTwoItems)?.ReplacePlaceholders(new Dictionary<string, object>
{
{ "firstitem", items[^2].Name },
{ "seconditem", items[^1].Name }
});
}) ?? string.Empty;

if (items.Length > 2)
{
StringBuilder itemSectionBuilder = new();
foreach (var component in items[..^2].Select(item => itemLineTextList.Get(ItemLineText.EarlierItem).Replace("{item}", item.Name)))
foreach (var component in items[..^2].Select(item => itemLineTextList.Get(ItemLineText.EarlierItem)?.Replace("{item}", item.Name)))
itemSectionBuilder.Append(component);

itemSectionBuilder.Append(itemSection);
itemSection = itemSectionBuilder.ToString();
}

return itemLineTextList.Get(ItemLineText.MultipleItemsFormat).Replace("{items}", itemSection);
return itemLineTextList?.Get(ItemLineText.MultipleItemsFormat)?.Replace("{items}", itemSection);
}

private string? GetWayLine(Room room)
Expand All @@ -209,30 +209,30 @@ private void AddRoomInformation(List<string> texts, Room playerRoom)
var wayLineTextList = wayLineTexts.ToArray();

if (ways.Length == 1)
return wayLineTextList.Get(WayLineText.SingleWay).Replace("{way}", wayLineTextList.Get(ways[0]));
return wayLineTextList.Get(WayLineText.SingleWay)?.Replace("{way}", wayLineTextList.Get(ways[0]));

string waySection = wayLineTextList.Get(WayLineText.LastTwoWays).ReplacePlaceholders(new Dictionary<string, object>
string waySection = wayLineTextList.Get(WayLineText.LastTwoWays)?.ReplacePlaceholders(new Dictionary<string, object>
{
{ "firstway", wayLineTextList.Get(ways[^2]) },
{ "secondway", wayLineTextList.Get(ways[^1]) }
});
{ "firstway", wayLineTextList?.Get(ways[^2]) ?? string.Empty },
{ "secondway", wayLineTextList?.Get(ways[^1]) ?? string.Empty }
}) ?? string.Empty;

if (ways.Length > 2)
{
StringBuilder waySectionBuilder = new();
foreach (var component in ways[..^2].Select(way => wayLineTextList.Get(WayLineText.EarlierWay).Replace("{way}", wayLineTextList.Get(way))))
foreach (var component in ways[..^2].Select(way => wayLineTextList?.Get(WayLineText.EarlierWay)?.Replace("{way}", wayLineTextList.Get(way))))
waySectionBuilder.Append(component);

waySectionBuilder.Append(waySection);
waySection = waySectionBuilder.ToString();
}

return wayLineTextList.Get(WayLineText.MultipleWayFormat).Replace("{ways}", waySection);
return wayLineTextList?.Get(WayLineText.MultipleWayFormat)?.Replace("{ways}", waySection);
}

private static (List<string> texts, bool isAnimateTriggered) ProgressPresentAnimateStatuses(ICollection<Animate> presentAnimates)
private static (List<string?> texts, bool isAnimateTriggered) ProgressPresentAnimateStatuses(ICollection<Animate> presentAnimates)
{
var texts = new List<string>();
var texts = new List<string?>();
bool isAnimateTriggered = false;

foreach (var animate in presentAnimates)
Expand All @@ -257,7 +257,7 @@ private Result DoPostRunProcessing(Result result)
if (!result.IsSuccess && !result.IsFailure)
return result;

var texts = new List<string>();
var texts = new List<string?>();

texts.AddRangeIfNotNull(result.Message);

Expand Down
2 changes: 1 addition & 1 deletion src/R136.Core/Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public StringValues RoomStatus
if (!ValidateStep(NextStep.ShowRoomStatus))
return StringValues.Empty;

List<string> texts = new();
List<string?> texts = new();

Room playerRoom = this.player!.CurrentRoom;
AddRoomInformation(texts, playerRoom);
Expand Down
14 changes: 5 additions & 9 deletions src/R136.Core/R136.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\SolutionInfo.cs" Link="SolutionInfo.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\R136.Entities\R136.Entities.csproj" />
<ProjectReference Include="..\R136.Interfaces\R136.Interfaces.csproj" />
</ItemGroup>

</Project>
</Project>
12 changes: 6 additions & 6 deletions src/R136.Entities/Animate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,13 @@ public class Snapshot : ISnapshot
public int StrikesLeft { get; set; }
public bool IsTriggered { get; set; }

public void AddBytes(List<byte> bytes)
public void AddBytesTo(List<byte> bytes)
{
ID.AddByte(bytes);
Room.AddByte(bytes);
Status.AddByte(bytes);
IsTriggered.AddByte(bytes);
StrikesLeft.AddBytes(bytes);
ID.AddByteTo(bytes);
Room.AddByteTo(bytes);
Status.AddByteTo(bytes);
IsTriggered.AddByteTo(bytes);
StrikesLeft.AddBytesTo(bytes);
}

public int? LoadBytes(ReadOnlyMemory<byte> bytes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ private static StringValues GetTexts<TIndex>(CommandID commandID, TIndex textId,
private static StringValues GetTexts<TIndex>(TIndex id) where TIndex : Enum
=> GetTexts(CommandID.End, id);

private static void AddStatusTexts(List<string> list, StatusTextID id)
private static void AddStatusTexts(List<string?> list, StatusTextID id)
=> list.AddRangeIfNotNull(GetTexts(CommandID.Status, id));
private static void AddStatusTexts(List<string> list, StatusTextID id, string tag, string content)
private static void AddStatusTexts(List<string?> list, StatusTextID id, string tag, string content)
=> list.AddRangeIfNotNull(GetTexts(CommandID.Status, id, tag, content));

private Result? ValidateEmptyParameters(string command, string? parameters)
Expand Down Expand Up @@ -71,7 +71,7 @@ private Result ExecuteWait(string command, string? parameters)

var waitTexts = GetTexts(CommandID.Wait, TextID.Default).ToArray();

return waitTexts == null ? Result.Success() : Result.Success(waitTexts[Facilities.Randomizer.Next(waitTexts.Length)]);
return waitTexts == null ? Result.Success() : Result.Success(waitTexts[Facilities.Randomizer.Next(waitTexts.Length)] ?? string.Empty);
}

private Result ExecuteStatus(string command, string? parameters, Player player)
Expand All @@ -81,7 +81,7 @@ private Result ExecuteStatus(string command, string? parameters, Player player)
if (validateResult != null)
return validateResult;

List<string> texts = new();
List<string?> texts = new();

AddStatusTexts(texts, StatusTextID.Header);
AddStatusTexts(texts, StatusTextID.LifePoints, "lifepoints", player.LifePoints.ToString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public class Snapshot : ISnapshot
{
public int PaperRouteIndex { get; set; }

public void AddBytes(List<byte> bytes)
=> PaperRouteIndex.AddBytes(bytes);
public void AddBytesTo(List<byte> bytes)
=> PaperRouteIndex.AddBytesTo(bytes);

public int? LoadBytes(ReadOnlyMemory<byte> bytes)
{
Expand Down
4 changes: 3 additions & 1 deletion src/R136.Entities/General/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static void AddRangeIfNotNull<T>(this List<T> list, IEnumerable<T>? colle
}

public static StringValues ReplaceInAll(this StringValues collection, string from, string to)
=> collection.Select(s => s.Replace(from, to)).ToArray();
=> collection.Select(s => (s ?? string.Empty).Replace(from, to)).ToArray();

public static (Item? item, FindResult result) FindItemByName(this List<Item> list, string s)
{
Expand All @@ -38,6 +38,8 @@ public static (int index, string? found) IndexOfAny(this string subject, StringV

foreach (var substring in substrings)
{
if (substring == null)
continue;
int index = subject.IndexOf(substring);
if (index >= 0)
return (index, substring);
Expand Down
18 changes: 9 additions & 9 deletions src/R136.Entities/Global/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ public class Configuration : LayoutProperties, ISnapshot
public bool AutoOpenConnections { get; set; } = false;
public bool EnableConfigList { get; set; } = false;

public void AddBytes(List<byte> bytes)
public void AddBytesTo(List<byte> bytes)
{
Immortal.AddByte(bytes);
FreezeAnimates.AddByte(bytes);
AutoPlaceItems.AddByte(bytes);
AutoOpenConnections.AddByte(bytes);
EnableConfigList.AddByte(bytes);
LifePoints.AddBytes(bytes);
LampPoints.AddIntBytes(bytes);
MaxInventory.AddIntBytes(bytes);
Immortal.AddByteTo(bytes);
FreezeAnimates.AddByteTo(bytes);
AutoPlaceItems.AddByteTo(bytes);
AutoOpenConnections.AddByteTo(bytes);
EnableConfigList.AddByteTo(bytes);
LifePoints.AddBytesTo(bytes);
LampPoints.AddIntBytesTo(bytes);
MaxInventory.AddIntBytesTo(bytes);
}


Expand Down
6 changes: 3 additions & 3 deletions src/R136.Entities/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ public class Snapshot : ISnapshot
public ItemID ID { get; set; }
public RoomID Room { get; set; }

public virtual void AddBytes(List<byte> bytes)
public virtual void AddBytesTo(List<byte> bytes)
{
ID.AddByte(bytes);
Room.AddByte(bytes);
ID.AddByteTo(bytes);
Room.AddByteTo(bytes);
}

public virtual int? LoadBytes(ReadOnlyMemory<byte> bytes)
Expand Down
12 changes: 6 additions & 6 deletions src/R136.Entities/Items/Flashlight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ public void Configure(IServiceProvider serviceProvider)
public bool IsOn { get; set; }
public bool HasBatteries { get; set; }

public override void AddBytes(List<byte> bytes)
public override void AddBytesTo(List<byte> bytes)
{
base.AddBytes(bytes);
IsOn.AddByte(bytes);
HasBatteries.AddByte(bytes);
LampPoints.AddIntBytes(bytes);
LampPointsFromConfig.AddIntBytes(bytes);
base.AddBytesTo(bytes);
IsOn.AddByteTo(bytes);
HasBatteries.AddByteTo(bytes);
LampPoints.AddIntBytesTo(bytes);
LampPointsFromConfig.AddIntBytesTo(bytes);
}

public override int? LoadBytes(ReadOnlyMemory<byte> bytes)
Expand Down
4 changes: 2 additions & 2 deletions src/R136.Entities/Items/Sword.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public override Result UseOn(Animate animate)
if (animate is not StrikableAnimate strikable || !UsableOn.Contains(animate))
return Use();

List<string> texts = new();
List<string?> texts = new();

if (Facilities.Randomizer.NextDouble() > .7)
AddTexts(texts, TextID.Miss);
Expand Down Expand Up @@ -76,7 +76,7 @@ public override Result UseOn(Animate animate)
);
}

private void AddTexts(List<string> texts, TextID id)
private void AddTexts(List<string?> texts, TextID id)
=> texts.AddRangeIfNotNull(Facilities.TextsMap.Get(this, id));

public Result Continue(ContinuationStatus status, string input)
Expand Down
10 changes: 5 additions & 5 deletions src/R136.Entities/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ public class Snapshot : IRoomsReader, IItemsReader, ISnapshot
[JsonIgnore]
public IReadOnlyDictionary<RoomID, Room>? Rooms { get; set; }

public void AddBytes(List<byte> bytes)
public void AddBytesTo(List<byte> bytes)
{
Room.AddByte(bytes);
LifePoints.AddIntBytes(bytes);
LifePointsFromConfig.AddIntBytes(bytes);
Inventory.AddEnumsBytes(bytes);
Room.AddByteTo(bytes);
LifePoints.AddIntBytesTo(bytes);
LifePointsFromConfig.AddIntBytesTo(bytes);
Inventory.AddEnumsBytesTo(bytes);
}

public int? LoadBytes(ReadOnlyMemory<byte> bytes)
Expand Down
Loading

0 comments on commit ec95dc7

Please sign in to comment.