Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to .NET Core 3 #4

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e077c42
build against 3.0
negativeeddy Sep 25, 2019
0c4be28
enabled non-nullable reference and fixed some issues
negativeeddy Sep 25, 2019
0e4abdb
code cleanup based on new analyzers and new c# syntax
negativeeddy Sep 25, 2019
9c6b6b5
remove unnecessary variable
negativeeddy Sep 25, 2019
ee40481
code cleanup
negativeeddy Sep 25, 2019
dd771b3
replace string extensions with String.Join
negativeeddy Sep 25, 2019
be48d74
remove old comments
negativeeddy Sep 25, 2019
93334e7
passing all unit tests!
negativeeddy Sep 26, 2019
9211188
nullable update for zoperand
negativeeddy Sep 26, 2019
1ddba26
document meaning of null Store property
negativeeddy Sep 26, 2019
45bdc55
nullable private field
negativeeddy Sep 26, 2019
25f386d
remove unused code
negativeeddy Sep 26, 2019
c04a58f
param doesnt support null
negativeeddy Sep 26, 2019
b2b76eb
dont use null
negativeeddy Sep 26, 2019
fdef09a
dont allow return from first stackframe
negativeeddy Sep 26, 2019
f2590be
remove unused code
negativeeddy Sep 26, 2019
e45fd14
remove unused code
negativeeddy Sep 26, 2019
6be9782
re-add the removed serailzation constructor
negativeeddy Sep 26, 2019
c2e905d
more nullable fixins
negativeeddy Sep 26, 2019
b0eae93
fix nullable warnings
negativeeddy Sep 26, 2019
b917ad1
style
negativeeddy Sep 26, 2019
181067a
nullable
negativeeddy Sep 26, 2019
e040e86
removing unused property which was complicating serialization
negativeeddy Sep 26, 2019
5cd2beb
remove unused parameter
negativeeddy Sep 26, 2019
4de1d46
simplifying test
negativeeddy Sep 26, 2019
088e4c7
mark Input nullable
negativeeddy Oct 27, 2019
0794d48
add performance tests
negativeeddy Mar 18, 2020
c498a06
disable perf tests
negativeeddy Oct 25, 2021
ea242af
update to .NET 6
negativeeddy Oct 25, 2021
856ea40
simplify new expression
negativeeddy Oct 25, 2021
d7a4f26
upgrade to latest C#
negativeeddy Oct 25, 2021
57ab4d9
using implicit namespaces and file scoped namespaces
negativeeddy Oct 25, 2021
391f365
simplify startup with top level statements
negativeeddy Oct 25, 2021
55e5b84
updating syntax
negativeeddy Oct 25, 2021
bd31cfd
nulls and optimizations
negativeeddy Oct 25, 2021
c29d480
nulls and style changes
negativeeddy Oct 25, 2021
83f0fba
fixing namespaces
negativeeddy Oct 25, 2021
d2bdbe8
updating style
negativeeddy Oct 25, 2021
ca2a074
update style
negativeeddy Oct 25, 2021
f779ffe
change BranchOffset to use Span
negativeeddy Oct 25, 2021
3796d92
style
negativeeddy Oct 25, 2021
8e017c0
make ZOperand a record
negativeeddy Oct 26, 2021
37df513
style changes to tests
negativeeddy Oct 26, 2021
8f44646
use switch expression
negativeeddy Oct 26, 2021
fb5f012
IList<> to Memory/Span
negativeeddy Oct 27, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
enabled non-nullable reference and fixed some issues
negativeeddy committed Sep 25, 2019
commit 0c4be28ee384e986594807714d2f898cb66a998d
10 changes: 2 additions & 8 deletions src/NegativeEddy.Leaflet.CoreConsoleHost/ConsoleInput.cs
Original file line number Diff line number Diff line change
@@ -5,14 +5,8 @@ namespace NegativeEddy.Leaflet.CoreConsoleHost
{
class ConsoleInput : IZInput
{
public char ReadChar()
{
return Console.ReadKey().KeyChar;
}
public char ReadChar() => Console.ReadKey().KeyChar;

public string ReadLine()
{
return Console.ReadLine();
}
public string ReadLine() => Console.ReadLine();
}
}
Original file line number Diff line number Diff line change
@@ -9,12 +9,14 @@
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<Nullable>enable</Nullable>
<LangVersion>8.0</LangVersion>
</PropertyGroup>

<ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NegativeEddy.Leaflet\NegativeEddy.Leaflet.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="GameFiles\**\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2 changes: 1 addition & 1 deletion src/NegativeEddy.Leaflet/IO/IOManager.cs
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ public InterpreterOutput()
private Subject<string> _outputSubject = new Subject<string>();
public IObservable<string> Print { get { return _outputSubject.AsObservable(); } }

public void WriteOutputLine(string text = null)
public void WriteOutputLine(string? text = null)
{
if (text != null)
{
4 changes: 2 additions & 2 deletions src/NegativeEddy.Leaflet/Instructions/BranchOffset.cs
Original file line number Diff line number Diff line change
@@ -4,9 +4,9 @@

namespace NegativeEddy.Leaflet.Instructions
{
public class BranchOffset
public struct BranchOffset
{
private IList<byte> _bytes;
private readonly IList<byte> _bytes;

public BranchOffset(IList<byte> bytes)
{
21 changes: 13 additions & 8 deletions src/NegativeEddy.Leaflet/Instructions/ZOpcode.cs
Original file line number Diff line number Diff line change
@@ -213,7 +213,7 @@ private int OperandAddress
}
}

private IList<ZOperand> _operands = null;
private IList<ZOperand>? _operands = null;
public IList<ZOperand> Operands
{
get
@@ -312,7 +312,7 @@ public ZVariable Store
}
else
{
return null;
throw new InvalidOperationException("ZOpcode does not have a store variable");
}
}
}
@@ -360,7 +360,7 @@ public BranchOffset BranchOffset
}
else
{
return null;
throw new InvalidOperationException("ZOpcode has no branch offset");
}
}
}
@@ -372,7 +372,7 @@ private int TextAddr
{
get
{
if (BranchOffset == null)
if (!Definition.HasBranch)
{
return BranchOffsetAddr;
}
@@ -383,7 +383,7 @@ private int TextAddr
}
}

private ZStringBuilder _textSection;
private ZStringBuilder? _textSection;

/// <summary>
/// The data for the Text portion of the instruction (if any)
@@ -392,11 +392,16 @@ private ZStringBuilder TextSection
{
get
{
if (_textSection == null && Definition.HasText)
if (!Definition.HasText)
{
_textSection = new ZStringBuilder(_bytes, TextAddr);
throw new InvalidOperationException("ZOpcode has no text section");
}

if (_textSection == null)
{
_textSection = new ZStringBuilder(_bytes, TextAddr);
}

return _textSection;
}
}
@@ -408,7 +413,7 @@ public string Text
{
get
{
return TextSection?.ToString();
return TextSection.ToString();
}
}

4 changes: 2 additions & 2 deletions src/NegativeEddy.Leaflet/Interpreter.cs
Original file line number Diff line number Diff line change
@@ -1189,9 +1189,9 @@ private void Handle_Opcode(ZOpcode opcode, Func<ZOpcode, int> handler)
/// <param name="opcode"></param>
private void BranchOrNext(ZOpcode opcode, int branchValue)
{
BranchOffset branch = opcode.BranchOffset;
if (branch != null)
if (opcode.Definition.HasBranch)
{
BranchOffset branch = opcode.BranchOffset;
// read the resulting value from the opcode store variable
bool branchIfIfOne = branch.WhenTrue;

6 changes: 1 addition & 5 deletions src/NegativeEddy.Leaflet/Memory/ZStringBuilder.cs
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ public ZStringBuilder(IList<byte> data, int index, int count)
}
}

private List<ushort> _allBits;
private List<ushort> _allBits = new List<ushort>();

public int LengthInBytes
{
@@ -53,10 +53,6 @@ public int LengthInBytes

public void AddWord(ushort bits)
{
if (_allBits == null)
{
_allBits = new List<ushort>();
}
_allBits.Add(bits);
}

3 changes: 2 additions & 1 deletion src/NegativeEddy.Leaflet/NegativeEddy.Leaflet.csproj
Original file line number Diff line number Diff line change
@@ -9,7 +9,8 @@
<Copyright>2016</Copyright>
<IncludeSymbols>True</IncludeSymbols>
<Description>An experimental implementation of the Infocom Z-Machine spec - aka "a Zork interpreter" - aka "30 year old tech built with modern tools"</Description>
</PropertyGroup>
<Nullable>enable</Nullable>
<LangVersion>8.0</LangVersion> </PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Reactive.Linq" Version="3.1.1" />
3 changes: 2 additions & 1 deletion src/NegativeEddy.Leaflet/Story/ZObject.cs
Original file line number Diff line number Diff line change
@@ -143,7 +143,7 @@ public string ShortName
}
}

private ZStringBuilder NameBuilder
private ZStringBuilder? NameBuilder
{
get
{
@@ -161,6 +161,7 @@ private ZStringBuilder NameBuilder
}
}
}

private int NameLengthInBytes { get { return NameBuilder?.LengthInBytes ?? 0; } }

public uint GetPropertyValue(int propertyID)