diff --git a/.github/ISSUE_TEMPLATE/build-error-and-visual-studio-problems.md b/.github/ISSUE_TEMPLATE/build-error-and-visual-studio-problems.md
index 8125653cb4..d53b7f251a 100644
--- a/.github/ISSUE_TEMPLATE/build-error-and-visual-studio-problems.md
+++ b/.github/ISSUE_TEMPLATE/build-error-and-visual-studio-problems.md
@@ -2,7 +2,7 @@
name: Build Error and Visual Studio Problems
about: For errors when trying to build a Cosmos Kernel or use VS
title: ''
-labels: ''
+labels: 'Area: Build, Area: Visual Studio Integration'
assignees: ''
---
@@ -24,6 +24,8 @@ If applicable, add screenshots to help explain your problem.
**Context**
Before posting please confirm that the following are in order
[ ] Both Cosmos VS Extensions are installed
-[ ] The Cosmos nuget packages are installed
+[ ] In the NuGet Package Manager "Include prerelease" is selected
+[ ] The Cosmos NuGet package store is selected (NOT nuget.org) in 'Manage NuGet Packages'
+[ ] The Cosmos NuGet packages are installed
Add any other context about the problem which might be helpful.
diff --git a/.github/ISSUE_TEMPLATE/docs_or_website.md b/.github/ISSUE_TEMPLATE/docs_or_website.md
new file mode 100644
index 0000000000..f94084d3af
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/docs_or_website.md
@@ -0,0 +1,16 @@
+---
+name: Documentation/Website Bug Report
+about: For bugs involving the Cosmos documentation & website
+title: ''
+labels: 'Area: Documentation'
+assignees: ''
+
+---
+
+#### URL of Documentation - What page of documentation are we dealing with?
+
+
+#### Expected Behaviour - What do you think should happen?
+
+
+#### Actual Behaviour - What is the issue?
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
deleted file mode 100644
index 5c6c65b4d3..0000000000
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ /dev/null
@@ -1,22 +0,0 @@
----
-name: Feature request
-about: Suggest an idea for Cosmos
-title: ''
-labels: Question
-assignees: ''
-
----
-
-Have you checked for similar suggestions?
-
-**Is your feature request related to a problem? Please describe.**
-A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
-
-**Describe the solution you'd like**
-A clear and concise description of what you want to happen.
-
-**Describe alternatives you've considered**
-A clear and concise description of any alternative solutions or features you've considered.
-
-**Additional context**
-Add any other context or screenshots about the feature request here.
diff --git a/.github/ISSUE_TEMPLATE/installation-problem.md b/.github/ISSUE_TEMPLATE/installation-problem.md
deleted file mode 100644
index daceee95c6..0000000000
--- a/.github/ISSUE_TEMPLATE/installation-problem.md
+++ /dev/null
@@ -1,28 +0,0 @@
----
-name: Installation Problem
-about: Create a report to help us improve
-title: ''
-labels: 'Area: Installer'
-assignees: ''
-
----
-
-**Describe the problem**
-A clear and concise description of where the installation is going wrong/what error messages you got.
-
-**Steps of installation up to now**
-What steps of the installation have you done up to now:
-
-**Expected behavior**
-A clear and concise description of what you expected to happen.
-
-**Logs**
-Please post the entire log given by Cosmos. For long logs please use pastebin.
-
-**Setup (please complete the following information):**
- - Cosmos Version (Userkit/Devkit)
- - Are you using an admin account?
- - VS Version if applicable
-
-**Additional context**
-Add any other context about the problem here.
diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml
new file mode 100644
index 0000000000..e823b432b5
--- /dev/null
+++ b/.github/workflows/stale.yml
@@ -0,0 +1,23 @@
+name: Mark stale issues and pull requests
+
+on:
+ schedule:
+ - cron: "30 1 * * *"
+
+jobs:
+ stale:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/stale@v3
+ with:
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
+ stale-issue-message: 'As this issue has received no new activity, it has been marked as stale'
+ stale-pr-message: 'As this pull request has received no new activity, it has been marked as stale'
+ stale-issue-label: 'no-issue-activity'
+ stale-pr-label: 'no-pr-activity'
+ exempt-issue-labels: 'Up for Grabs,Blocked,PR submitted'
+ exempt-pr-labels: 'Work in progress'
+ exempt-all-milestones: true
+ exempt-all-assignees: true
diff --git a/Docs/articles/GettingStarted.md b/Docs/articles/GettingStarted.md
index d5f5cd6ec1..44b470a25c 100644
--- a/Docs/articles/GettingStarted.md
+++ b/Docs/articles/GettingStarted.md
@@ -27,8 +27,8 @@ so overwhelming like the dev kit. This article focuses on the user kit.
## Writing your first Operating System
-Create a new project as you would any C# project, but select Cosmos as the
-project type.
+Create a new project as you would any C# project, but select Cosmos Kernel
+(Previously CosmosBoot; same functionality) as the project type.

@@ -126,7 +126,7 @@ and it will appear in the Visual Studio output window.
## What's the catch?
-There really is no catch. Everything We've shown here is functioning as seen.
+There really is no catch. Everything we've shown here is functioning as seen.
No mockups were used. However we still have a lot of work to go. Items of
interest that are on our current task list include interfaces (necessary for
foreach loops), file systems (partial support exists), threads, networking, and
@@ -137,7 +137,7 @@ rolled into the mainline Cosmos development as of yet.
Cosmos does not run on Linux. A boot loader called Syslinux is used to boot
Cosmos. After booting, Syslinux is not used. Syslinux is a bootloader and is
-not a Linux distro. Syslinux simplifies the booting process by doing tasks such as enabline the A20 gate, initializing hardware, and switching to real mode (all of which are required by modern operating systems).
+not a Linux distro. Syslinux simplifies the booting process by doing tasks such as enabling the A20 gate, initializing hardware, and switching to real mode (all of which are required by modern operating systems).
## Obtaining Cosmos
diff --git a/Docs/articles/Kernel/CGS.md b/Docs/articles/Kernel/CGS.md
index 266546c166..476a97606d 100644
--- a/Docs/articles/Kernel/CGS.md
+++ b/Docs/articles/Kernel/CGS.md
@@ -1,8 +1,8 @@
# Introduction
-The Cosmos Graphic Subsystem (CGS from now on) is based on the abstraction of Canvas that is an empty space in which the user of CGS can draw its content. CGS is not a widget toolkit as Winforms or Gnome / GTK but is tough to be more lower level and it will be the basic in which widget toolkits will be implemented. CGS hides the graphics driver (so far VGA and VBE) used and it is tough to be the universal way to draw on the screen in Cosmos.
+The Cosmos Graphic Subsystem (CGS from now on) is based on the abstraction of Canvas that is an empty space in which the user of CGS can draw its content. CGS is not a widget toolkit as Winforms or Gnome / GTK but is thought to be more lower level and it will be the basic in which widget toolkits will be implemented. CGS hides the graphics driver (so far VGA, VBE and SVGA II) used and it is thought to be the universal way to draw on the screen in Cosmos.
-While Canvas could be overwritten (for example to create sub windows) the user of CGS does not have to deal with it directly but it must use the static class FullScreenCanvas.
+While Canvas could be overwritten (for example to create sub windows) the user of CGS does not have to deal with it directly but they must use the static class FullScreenCanvas.
Let's give a look to its API methods.
# FullScreenCanvas
@@ -24,6 +24,10 @@ To really draw into the screen we need to use the Canvas class. Let's give a loo
void DrawPoint(Pen pen, int x, int y) draws a point at the coordinates specified by x and y with the specified pen
void DrawLine(Pen pen, int x_start, int y_start, int x_end, int y_end) draws a line at the coordinates specified by x_start, y_start and x_end, y_end with the specified pen
void DrawRectangle(Pen pen, int x_start, int y_start,int width, int height) draws a rectangle specified by a coordinate pair, a width, and a height with the specified pen
+ void DrawImage(Image image, int x, int y) draws an image at the x and y specified
+ void DrawString(String string, Font font, Brush brush, int x, int y) draws a string with the specified font and brush at the specified x and y coordinates
+ void Display() only for double buffering, swaps the 2 buffers then display everything to the screen
+
Really simple right?
# A working example
@@ -38,13 +42,31 @@ namespace GraphicTest
{
Canvas canvas;
+ private readonly Bitmap bitmap = new Bitmap(10, 10,
+ new byte[] { 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0,
+ 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255,
+ 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255,
+ 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 23, 59, 88, 255,
+ 23, 59, 88, 255, 0, 255, 243, 255, 0, 255, 243, 255, 23, 59, 88, 255, 23, 59, 88, 255, 0, 255, 243, 255, 0,
+ 255, 243, 255, 0, 255, 243, 255, 23, 59, 88, 255, 153, 57, 12, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255,
+ 243, 255, 0, 255, 243, 255, 153, 57, 12, 255, 23, 59, 88, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243,
+ 255, 0, 255, 243, 255, 0, 255, 243, 255, 72, 72, 72, 255, 72, 72, 72, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0,
+ 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 72, 72,
+ 72, 255, 72, 72, 72, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255,
+ 10, 66, 148, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255,
+ 243, 255, 10, 66, 148, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 10, 66, 148, 255, 10, 66, 148, 255,
+ 10, 66, 148, 255, 10, 66, 148, 255, 10, 66, 148, 255, 10, 66, 148, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255,
+ 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 10, 66, 148, 255, 10, 66, 148, 255, 10, 66, 148, 255, 10, 66, 148,
+ 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255,
+ 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, 0, 255, 243, 255, }, ColorDepth.ColorDepth32);
+
protected override void BeforeRun()
{
- /* If all works correctly you should not really see this :-) */
- Console.WriteLine("Cosmos booted successfully. Let's go in Graphic Mode");
-
- canvas = FullScreenCanvas.GetFullScreenCanvas();
+ // If all works correctly you should not really see this :-)
+ Console.WriteLine("Cosmos booted successfully. Let's go in Graphical Mode");
+ // You don't have to specify the Mode, but here we do to show that you can.
+ canvas = FullScreenCanvas.GetFullScreenCanvas(new Mode(640, 480, ColorDepth.ColorDepth32));
canvas.Clear(Color.Blue);
}
@@ -52,58 +74,52 @@ namespace GraphicTest
{
try
{
- /* A red Point */
Pen pen = new Pen(Color.Red);
+
+ // A red Point
canvas.DrawPoint(pen, 69, 69);
- /* A GreenYellow horizontal line */
+ // A GreenYellow horizontal line
pen.Color = Color.GreenYellow;
canvas.DrawLine(pen, 250, 100, 400, 100);
- /* An IndianRed vertical line */
+ // An IndianRed vertical line
pen.Color = Color.IndianRed;
canvas.DrawLine(pen, 350, 150, 350, 250);
- /* A MintCream diagonal line */
+ // A MintCream diagonal line
pen.Color = Color.MintCream;
canvas.DrawLine(pen, 250, 150, 400, 250);
- /* A PaleVioletRed rectangle */
+ // A PaleVioletRed rectangle
pen.Color = Color.PaleVioletRed;
canvas.DrawRectangle(pen, 350, 350, 80, 60);
- Console.ReadKey();
-
- /* Let's try to change mode...*/
- canvas.Mode = new Mode(800, 600, ColorDepth.ColorDepth32);
-
- /* A LimeGreen rectangle */
+ // A LimeGreen rectangle
pen.Color = Color.LimeGreen;
canvas.DrawRectangle(pen, 450, 450, 80, 60);
- Console.ReadKey();
+ // A bitmap
+ canvas.DrawImage(bitmap, new Point(100, 150));
- Stop();
+ Console.ReadKey();
+ Sys.Power.Shutdown();
}
catch (Exception e)
{
mDebugger.Send("Exception occurred: " + e.Message);
- mDebugger.Send(e.Message);
- Stop();
+ Sys.Power.Shutdown();
}
}
}
}
```
-# Limitation of the current implementation
-
-1. Only the Bochs Graphic Adapter is actually supported; this means that CGS will work only on Bochs, QEMU and VirtualBox. CGS does not make any assumption on the underlying hardware, simple a VGA driver should be adapted to use it. No change to user code should be required to use another driver
-2. Only 32 bit color depth is actually supported, the API provides methods to set a resolution with 24, 16, 8 and 4 bit but the low level Bochs driver has not yet implemented them
-3. CGS does not permits yet to do basic operations that would permit to fulfill its promise to be the basic block from which a "Widget Toolkit" could be derived for example these methods should be added:
- DrawFilledRectangle((Pen pen, int x_start, int y_start,int width, int height)
- void DrawImage(Image image, int x, int y) Canvas has already defined this method but it is not yet implemented
- void DrawString(String string, Font font, Brush brush, int x, int y) Canvas has already defined this method but it is not yet implemented
- .Net System.Drawing has overload of these methods taking a float to evaluate if they are really needed for CGS, they are defined but for now no implementation is provided
- A double buffering strategy could be implemented to make it faster
- This is more a limitation of the Bochs driver when the Graphic Mode is set there is no more a way to return to text mode
- CGS / Graphic Mode interacts badly with the Kernel.Stop method: Bochs does not exit cleanly. You must use Sys.Power.Shutdown to shut down correctly your computer.
+# Limitations of the current implementation
+
+1. Only 32 bit color depth is actually supported, the API provides methods to set a resolution with 24, 16, 8 and 4 bit but the low level Bochs driver has not yet implemented them.
+
+2. In addition, some other nice things could be implemented:
+ - Plugging System.Drawing functions for easier manipulation of colors
+ - A double buffering strategy, to make drawing faster (one is already implemented in the VBE driver, but not VGA or SVGA II)
+
+3. CGS interacts badly with the Kernel.Stop method: the screen will freeze without displaying any error message whatsoever. You must use the Sys.Power.Shutdown() function to properly shut down your computer.
diff --git a/Docs/articles/Kernel/Network.md b/Docs/articles/Kernel/Network.md
new file mode 100644
index 0000000000..2f8ed5ab3e
--- /dev/null
+++ b/Docs/articles/Kernel/Network.md
@@ -0,0 +1,141 @@
+# Network
+
+In this article we will discuss about Networking on Cosmos, how to use the Network Stack, send and receive packets. For now, available protocols are **ARP**, **IPv4**, **TCP**, **UDP**, **ICMP**, **DHCP** and **DNS**. Note that Cosmos devkit must be installed for this article.
+
+All protocols here don't necessary support every feature described by their RFC and may have some bugs or architecture issues, if you find bugs or something abnormal please [submit an issue](https://github.com/CosmosOS/Cosmos/issues/new/choose) on our repository.
+
+Each protocol has a Client class which can be used to receive and send data. If a Receive() method is blocking, the method will timeout after 5 seconds or use the value optionally set by parameter. Please note that all finished connections should be closed using Close().
+
+Cosmos Network Stack won't use Classes and Functions that are under .NET Core. Everything described here will be under:
+```csharp
+using Cosmos.System.Network;
+```
+
+Before anything, a Network Configuration must be set (local machine IPv4 address, subnet mask and gateway). It can be manually set with IPConfig.Enable or dynamically set through a DHCP server. For DHCP, Cosmos will ask to the DHCP server (usually default gateway) for an address in your local network.
+
+### Manually set IPv4 Config
+```csharp
+NetworkDevice nic = NetworkDevice.GetDeviceByName("eth0"); //get network device by name
+IPConfig.Enable(nic, new Address(192, 168, 1, 69), new Address(255, 255, 255, 0), new Address(192, 168, 1, 254)); //enable IPv4 configuration
+```
+### Dynamically set IPv4 Config through DHCP
+```csharp
+using(var xClient = new DHCPClient())
+{
+ /** Send a DHCP Discover packet **/
+ //This will automatically set the IP config after DHCP response
+ xClient.SendDiscoverPacket();
+}
+```
+
+## TCP
+Like UDP, TCP has to create a client and call Connect() to specify the remote machine address before sending or receiving data.
+
+Server :
+```csharp
+using(var xServer = new TcpListener(4242))
+{
+ /** Start server **/
+ xServer.Start();
+
+ /** Accept incoming TCP connection **/
+ var client = xServer.AcceptTcpClient(); //blocking
+
+ /** Stop server **/
+ xServer.Stop();
+
+ /** Send data **/
+ client.Send(Encoding.ASCII.GetBytes(message));
+}
+```
+
+Client :
+```csharp
+using(var xClient = new TcpClient(4242))
+{
+ xClient.Connect(new Address(192, 168, 1, 70), 4242);
+
+ /** Send data **/
+ xClient.Send(Encoding.ASCII.GetBytes(message));
+
+ /** Receive data **/
+ var endpoint = new EndPoint(Address.Zero, 0);
+ var data = xClient.Receive(ref endpoint); //set endpoint to remote machine IP:port
+ var data2 = xClient.NonBlockingReceive(ref endpoint); //retrieve receive buffer without waiting
+}
+```
+
+## FTP
+Only server side is implemented in Cosmos. We recommand to use FileZilla as your FTP client.
+
+**Your FTP client must enable active mode**. Since in Active Mode the server has to open TCP connections, **your computer firewall must be disabled** to accept incoming connection. An FTP connection is made of two TCP sockets. One for control connection (as a textual protocol) and one for data transmission. Data transmission sockets can be opened by the client (if it is in Passive Mode) or by the server (if in Active Mode). The Passive Mode is not supported yet due to current Cosmos TCP and multithreading limitation.
+
+FTP client configuration (plain FTP, Anonymous):
+
+
+
+Please note that for now only one FTP connection can be accepted, the server will shut down itself after the client disconnection.
+
+```csharp
+/** Initialize filesystem **/
+var fs = new CosmosVFS();
+VFSManager.RegisterVFS(fs);
+
+using(var xServer = new FtpServer(fs, "0:\\"))
+{
+ /** Listen for new FTP client connections **/
+ ftpSever.Listen();
+}
+```
+
+## UDP
+Before playing with packets, we have to create a client and call Connect() to specify the remote machine address. After that the client will be able to send or listen for data.
+```csharp
+using(var xClient = new UdpClient(4242))
+{
+ xClient.Connect(new Address(192, 168, 1, 70), 4242);
+
+ /** Send data **/
+ xClient.Send(Encoding.ASCII.GetBytes(message));
+
+ /** Receive data **/
+ var endpoint = new EndPoint(Address.Zero, 0);
+ var data = xClient.Receive(ref endpoint); //set endpoint to remote machine IP:port
+ var data2 = xClient.NonBlockingReceive(ref endpoint); //retrieve receive buffer without waiting
+}
+```
+
+## ICMP
+For ICMP, we will only be able to send an ICMP echo to a distant machine and wait for its response. If another machine sends us an ICMP echo, Cosmos will automatically handle the request and reply.
+```csharp
+using(var xClient = new ICMPClient())
+{
+ xClient.Connect(new Address(192, 168, 1, 254));
+
+ /** Send ICMP Echo **/
+ xClient.SendEcho();
+
+ /** Receive ICMP Response **/
+ int time = xClient.Receive(ref endpoint); //return elapsed time / timeout if no response
+}
+
+```
+## DNS
+DNS can be used to get an IP address from a Domain Name string. For now DNS can only ask for one domain name at the same time.
+```csharp
+using(var xClient = new DnsClient())
+{
+ xClient.Connect(new Address(192, 168, 1, 254)); //DNS Server address
+
+ /** Send DNS ask for a single domain name **/
+ xClient.SendAsk("github.com");
+
+ /** Receive DNS Response **/
+ Address destination = xClient.Receive(); //can set a timeout value
+}
+
+```
+## Get local IP address
+```csharp
+Console.WriteLine(NetworkConfig.CurrentConfig.Value.IPAddress.ToString());
+```
diff --git a/Docs/articles/Kernel/VFS.md b/Docs/articles/Kernel/VFS.md
index e75ced1811..5951202927 100644
--- a/Docs/articles/Kernel/VFS.md
+++ b/Docs/articles/Kernel/VFS.md
@@ -3,67 +3,86 @@
In this article we will discuss about using Cosmos VFS (virtual file system).
Cosmos VFS and the VFS manager classes, let you manage your file system.
+**Attention**: **Always** format your drive with Cosmos and **only** Cosmos if you plan to use it with Cosmos. Using any other tool such as Parted, FDisk (or any other tool) might lead to weird things when using that drive with Cosmos' VFS. Those tools are much more advanced and might format and read/write to the disk differently than Cosmos.
+
First, we should create and initialize an instance of the VFS, this will initialize the partition and files-system lists, as well as register the new VFS.
This is essential for using the VFS.
-We start with creating global CosmosVFS, this line should appear outside of any function, and before the BeforeRun() function.
+We start with creating a global CosmosVFS, this line should appear outside of any function, and before the BeforeRun() function.
```C#
-CosmosVFS fs = new Sys.FileSystem.CosmosVFS();
+Sys.FileSystem.CosmosVFS fs = new Sys.FileSystem.CosmosVFS();
```
-Next, we register our VFS at the VFS manager, this will initiate the VFS and make it usable, add this to your kernel's BeforeRun():
+Next, we register our VFS at the VFS manager, this will initiate the VFS and make it usable, add this to your kernel's BeforeRun() function:
```C#
Sys.FileSystem.VFS.VFSManager.RegisterVFS(fs);
```
-After the initialization process is done, a message like this would apper on your screen:
+After the initialization process is done, a message like this would appear on your screen:

-This message is printed by the register method and it provides info about the file system.
+This message is printed by the RegisterVFS() method and it provides info about the partition.
+
+**Note**: From now on, we'll be using some plugged functions from ``System.IO``, so be sure to use that reference to your code. Alright, now, let's get started over some useful functions:
+
+## Format drive
+
+**Note**: You don't have to format your drive if you're debugging your Cosmos project with VMWare. The build will automatically add an already formatted FAT32 VMDK file for your convenience.
-After our VFS has been initialized, we can use more interesting functions, lets go over some of them:
+**Note 2**: You can only format a drive that already has been formatted with FAT32.
+
+You can format your drive with the Format() function, just like this:
+
+```C#
+fs.Format("0" /*drive id*/, "FAT32" /*fat type*/, true /*use quick format*/);
+```
+
+**Attention**: **Don't** add anything after the drive id, or formatting won't work. You just need to put the drive id, here we put 0 to format the main drive.
## Get available free space
We use this function to get the size of the available free space in our file system, in bytes.
```C#
-long available_space = fs.GetAvailableFreeSpace("0:/");
+var available_space = fs.GetAvailableFreeSpace(@"0:\");
Console.WriteLine("Available Free Space: " + available_space);
```

-You have probably noticed the "0:/" argument passed to this function, this is the id of the drive that we want to get available free space of.
+You have probably noticed the "0:\" argument passed to this function, this is the id of the drive that we want to get available free space of.
Cosmos using DOS drive naming system and this is why we use "0".
+**Attention**: Typing "0:/" instead of "0:\" might lead to errors, you've been warned.
+
## Get file system type
This will let us know what is the file system type that we are using.
+You **should** be seeing "FAT32", if you see other types of FAT like "FAT16" or "FAT12", then the virtual disk has probably been formatted with one of those FAT types, but remember, the best supported one is FAT32.

```C#
-string fs_type = fs.GetFileSystemType("0:/");
+var fs_type = fs.GetFileSystemType(@"0:\");
Console.WriteLine("File System Type: " + fs_type);
```
## Get files list
-We start by getting the directory entrys list, using:
+We start by getting a list of files, using:
```C#
-var directory_list = fs.GetDirectoryListing("0:/");
+var directory_list = Directory.GetFiles(@"0:\");
```
Once we have it, we can get the names of our files:
```C#
-foreach (var directoryEntry in directory_list)
+foreach (var file in directory_list)
{
- Console.WriteLine(directoryEntry.mName);
+ Console.WriteLine(file);
}
```
@@ -72,36 +91,26 @@ foreach (var directoryEntry in directory_list)
## Read all the files in a directory
This one is more tricky,
-We need to get a directoryEntryList, find files in the list and print the content to the screen.
+We need to get a list of files and print all of their content to the screen.
-of course, we start with geting the directory listing;
+Of course, we'll start with geting that files list:
```C#
-var directory_list = fs.GetDirectoryListing("0:/");
+var directory_list = Directory.GetFiles(@"0:\");
```
-Now we can go through our list, and and print the txt file content.
+Now we can go through our list, and print the raw content of each file.
```C#
try
{
- foreach (var directoryEntry in directory_list)
+ foreach (var file in directory_list)
{
- var file_stream = directoryEntry.GetFileStream();
- var entry_type = directoryEntry.mEntryType;
- if(entry_type == Sys.FileSystem.Listing.DirectoryEntryTypeEnum.File)
- {
- byte[] content = new byte[file_stream.Length];
- file_stream.Read(content, 0, (int)file_stream.Length);
- Console.WriteLine("File name: " + directoryEntry.mName);
- Console.WriteLine("File size: " + directoryEntry.mSize);
- Console.WriteLine("Content: ");
- foreach (char ch in content)
- {
- Console.Write(ch.ToString());
- }
- Console.WriteLine();
- }
+ var content = File.ReadAllText(file);
+
+ Console.WriteLine("File name: " + file);
+ Console.WriteLine("File size: " + content.Length);
+ Console.WriteLine("Content: " + content);
}
}
catch(Exception e)
@@ -109,25 +118,17 @@ catch(Exception e)
Console.WriteLine(e.ToString());
}
```
-
-## Read specific file
+
-Now we will read specific file from a path.
-As usual, we do it in a try catch block.
+## Create new file
+Reading and writing is working on existing files, but it's much more useful to write to our own files.
+Let's jump right into it:
```C#
try
{
- var hello_file = fs.GetFile(@"0:\hello_from_elia.txt");
- var hello_file_stream = hello_file.GetFileStream();
-
- if (hello_file_stream.CanRead)
- {
- byte[] text_to_read = new byte[hello_file_stream.Length];
- hello_file_stream.Read(text_to_read, 0, (int)hello_file_stream.Length);
- Console.WriteLine(Encoding.Default.GetString(text_to_read));
- }
+ var file_stream = File.Create(@"0:\testing.txt");
}
catch (Exception e)
{
@@ -135,32 +136,20 @@ catch (Exception e)
}
```
-We use the GetFile() method, which returns a file from a path.
-Next we open a stream to the file and check if we can read it.
-The last thing we do is reading from the stream, we use Read() method, which write the stream to a byte array.
+We can also [check our files list](https://github.com/CosmosOS/Cosmos/wiki/FAT-FileSystem#get-files-list) and see our new file in it.
-
-
-Notice that there is no much difference between this and [read all the files in a directory](https://github.com/CosmosOS/Cosmos/wiki/FAT-FileSystem#read-all-the-files-in-a-directory).
-Actually the difference is by using GetFile() instead of GetDirectoryListing(), as the first returns single DirectoryEntry, and the second returns DirectoryEntryList.
+
-## Write to a file
+## Write to file
-Now we will write to an existing file.
-Writing to a file is almost the same as reading from a file.
-Always remember, we should use try catch block.
+Now we will write to an existing file.
+Writing to a file is almost the same as reading from a file.
+Always remember that we should put our code in a try catch block.
```C#
try
{
- var hello_file = fs.GetFile(@"0:\hello_from_elia.txt");
- var hello_file_stream = hello_file.GetFileStream();
-
- if (hello_file_stream.CanWrite)
- {
- byte[] text_to_write = Encoding.ASCII.GetBytes("Learning how to use VFS!");
- hello_file_stream.Write(text_to_write, 0, text_to_write.Length);
- }
+ File.WriteAllText(@"0:\testing.txt", "Learning how to use VFS!");
}
catch (Exception e)
{
@@ -168,18 +157,15 @@ catch (Exception e)
}
```
-Again we use the GetFile() method, which returns a file from a path.
-Next we open a stream to the file and check if we can write to it.
-The last thing we do is writing to the stream, we use Write() method, which write a byte array to the stream.
+## Read specific file
-## Create new file
-Reading and writing is working on existing files, but it's much more useful to write to our own files.
-let's jump right into it:
+Now we will read a specific file from a given path.
+As usual, we'll do it in a try catch block.
```C#
try
{
- fs.CreateFile(@"0:\hello_from_elia.txt");
+ Console.WriteLine(File.ReadAllText(@"0:\testing.txt"));
}
catch (Exception e)
{
@@ -187,7 +173,4 @@ catch (Exception e)
}
```
-This would create new, empty file (its size is 0 bytes), we can write to it by using [this method](https://github.com/CosmosOS/Cosmos/wiki/FAT-FileSystem/_edit#write-to-a-file).
-Now we can [check our files list](https://github.com/CosmosOS/Cosmos/wiki/FAT-FileSystem#get-files-list) and see our new file in it:
-
-
+
\ No newline at end of file
diff --git a/Docs/articles/toc.md b/Docs/articles/toc.md
index be98130663..99ddec63c6 100644
--- a/Docs/articles/toc.md
+++ b/Docs/articles/toc.md
@@ -19,6 +19,7 @@
## [Startup](Kernel/Startup.md)
## [Graphics](Kernel/CGS.md)
## [Virtual File System](Kernel/VFS.md)
+## [Network](Kernel/Network.md)
# Reference
## [x86](Reference/x86.md)
diff --git a/Docs/index.md b/Docs/index.md
index 81343a8b66..1ffee0f60b 100644
--- a/Docs/index.md
+++ b/Docs/index.md
@@ -1,9 +1,18 @@
-# Cosmos Documentation
+# Welcome to the Official Cosmos Documentation
+
+If you're new to Cosmos, welcome! Before you get stuck in the API documentation, we highly recommend you visit the website linked at the bottom.
+
+The Articles section of this website includes some articles which have been written many years ago for websites such as www.codeproject.com and are kept for archival purposes. These discuss elements such as the Cosmos Virtual File System. We prefer newcomers who want to develop their own operating systems to read the API documentation while we update these articles to comply with the current Cosmos project.
+
+For projects using the VFS directly, we recommend you use System.IO methods where possible. This is because these were written before much progress was made making .NET assemblies usable
+
+
+For the up-to-date API documentation generated from the master branch, please visit the [Cosmos API Documentation](https://cosmosos.github.io/api/Cosmos.Build.Tasks.html)
+
+If you're looking for general information about Cosmos e.g. our goals and various links to chat with us or for help with using Cosmos that can't be answered with existing documentation, please visit the [Cosmos website](https://gocosmos.org)
-
-Some docs are outdated, and we are currently working on updating them and adding new ones.
+You can find the latest and previous build statuses on [AppVeyor](https://ci.appveyor.com/project/CosmosOS/cosmos)
-
-
-*Looking for the [Cosmos website](https://gocosmos.org)?*
+[](https://ci.appveyor.com/project/CosmosOS/cosmos/branch/master)
+[](https://discord.com/invite/kwtBwv6jhD)
diff --git a/Docs/install.md b/Docs/install.md
new file mode 100644
index 0000000000..8ccec27bb7
--- /dev/null
+++ b/Docs/install.md
@@ -0,0 +1,76 @@
+### Prerequisites
+
+* **Visual Studio 2019** - [Download](https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx)
+* **Visual Studio 2019 Workload: .NET Core Tools** - .NET Core cross-platform development
+* **.NET Framework 4.6.2 Developer Pack** - [Download](https://www.microsoft.com/en-us/download/details.aspx?id=53321)
+* **VMware Player OR Workstation** VMware Player is free, so that is recommended instead - [Download](https://www.vmware.com/uk/products/workstation-player/workstation-player-evaluation.html)
+
+### Installing Cosmos
+
+First, you need to choose between the User Kit and the Dev Kit. It is recommended that new users start with the User Kit but only move later to the Dev Kit if you need the latest features and want to contribute back to the main project.
+The Dev Kit is the live source against which the Cosmos Team develops directly. The Dev Kit has the latest and greatest features, but at various times has known issues, and sometimes may not even build. Thus to use the Dev Kit be sure to join our support channels and inquire about the current status before using the Dev Kit or updating it.
+
+The User Kit is a snapshot stable version of Cosmos including a premade installer. The UserKit however is often quite a bit out of date compared to the DevKit and is only occasionally updated. The User Kit is a great easy way to get familiar with Cosmos, but active developers should transition to the Dev Kit after becoming very familiar with the UserKit, and expect some bugs here and there.
+
+### User Kit
+
+1. Download [the latest release of Cosmos](http://github.com/CosmosOS/Cosmos/releases/latest) (download the **exe** file)
+2. Wait for the download to complete then run the installer. Allow it to run as admin. Make sure **VS2019 is NOT running** when you do this.
+3. Click "Next" then "Install"
+4. Wait for the install to progress. **Tip:** At the end the installer may look like it has stalled, but it is still doing something in the background. WAIT for the "Finish" button to become available.
+5. Cosmos should now be installed. Follow other tutorials to find out how to create your first OS.
+
+### Dev Kit
+
+##### **Additional Prerequisites**
+
+* **Visual Studio 2019 Workload: Visual Studio Extension Development**
+* **Inno Quick Start Pack (Free)** – Install with defaults, keep Preprocessor option checked [Download](http://www.jrsoftware.org/isdl.php#qsp)
+* **.NET Core 2.0 SDK** - [Download](https://www.microsoft.com/net/download/core)
+
+##### Get the Source
+
+Cosmos source is hosted at GitHub. The simplest method to obtain the source is download a .zip file, however this makes updating and getting the latest updates a bit tricky.
+To update the Cosmos source more efficiently, use the Git command line, or any of the many Git User Interfaces. Any frontend may work fine but for users new to Git, we suggest [GitHub Desktop](https://desktop.github.com/). For more experienced Git users, we really like [Git Kraken](https://www.gitkraken.com/). Git Kraken is free for non-commercial use such as Cosmos. SourceTree, Git GUI, and others are also available.
+
+To aid in better encapsulation and to invite more developers to assist in various areas, Cosmos is split into four Git repositories. Each of these is designed to be an independent project although Cosmos relies on the other three.
+You will need to pull the source for all four repositories and they must exist in sibling directories as shown in the diagram below. The Cosmos base directory can be named anything and exist anywhere. But the directories inside it must match exactly.
+
+Windows is not case sensitive for files, but many of the ._**NET Core tools used to build are case sensitive even on Windows for file paths**_. Make sure to create the subdirectories exactly as shown. For demonstration purposes let us assume that you will use c:\\source\\Cosmos to install to.
+This base directory is referred to as the Cosmos directory. Each of the four repositories then must be cloned or extracted to the corresponding sub folder of the Cosmos directory. Using this example, the set up should look like this:
+```
+c:\\source\\CosmosOS\\
+c:\\source\\CosmosOS\\Cosmos\\ - [Git Repository for Cosmos](https://github.com/CosmosOS/Cosmos)
+c:\\source\\CosmosOS\\IL2CPU\\ - [Git Repository for IL2CPU](https://github.com/CosmosOS/IL2CPU)
+c:\\source\\CosmosOS\\XSharp\\ - [Git Repository for XSharp](https://github.com/CosmosOS/XSharp)
+c:\\source\\CosmosOS\\Common\\ - [Git Repository for Common](https://github.com/CosmosOS/Common)
+```
+A tree diagram of the source should look like the following:
+
+
+We are working to make syncing code easier. We have already experimented with Git Submodules, however the simple use of submodules presents a few issues, but the biggest of them is that they trigger a fireworks show of problems and errors in every Git UI we tried and would have limited developers options and forced them to the command line in most cases. We are currently investigating subtrees.
+
+For now, it's much easier to handle the 4 repositories as most of the time, new Cosmos developers may only have to work in the Cosmos repository. Only when you are comfortable with the concept of Operating System development and C# should you venture into IL2CPU and XSharp.
+
+If you want to keep your source up to date in a one-click method, paste this code into a .bat file in the CosmosOS folder ( as shown in the above example). This .bat file will only work after the repositories have been cloned with git at least once.
+
+cd C:\\XSharp
+git pull
+cd ..\\IL2CPU
+git pull
+cd ..\\Cosmos
+git pull
+cd ..\\Common
+git pull
+cd ..
+
+##### Building and Installing
+
+(if you have already installed) If you edited the Cosmos DevKit source using _Cosmos.sln_ or _Test.sln_, be sure to set solution config to **Debug x86**.
+
+1. Make sure Visual Studio is **NOT running**.
+2. In the root directory of the DevKit files, you downloaded earlier, run `install-VS2019.bat`.
+3. Wait for the install to progress. (**Tip:** At the end the installer may look like it is stalling, it is still doing something, just in the background)
+4. VS will open with Cosmos loaded. You can now make changes to core assemblies of Cosmos. If you don't want to, you can close this VS window and create a new Cosmos project as with the user kit.
+
+Happy Cosmos-ing!
diff --git a/Docs/toc.yml b/Docs/toc.yml
index c2aa3372cb..18cb3ce677 100644
--- a/Docs/toc.yml
+++ b/Docs/toc.yml
@@ -1,5 +1,7 @@
- name: Home
href: index.md
+- name: Install
+ href: install.md
- name: Cosmos Website
href: https://gocosmos.org
- name: Articles
diff --git a/LICENSE.txt b/LICENSE.txt
index 60a301dfab..6034fa5e96 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,21 +1,21 @@
BSD 3-Clause License
-Copyright (c) 2019, COSMOS Project
+Copyright (c) 2021, CosmosOS, COSMOS Project
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
+1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
-* Neither the name of the copyright holder nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
+3. Neither the name of the copyright holder nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
diff --git a/README.md b/README.md
index eceb80016a..7f2e0ed712 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,14 @@
# Cosmos
[](https://ci.appveyor.com/project/CosmosOS/cosmos/branch/master)
+[](https://discord.com/invite/kwtBwv6jhD)
Cosmos is an operating system "construction kit". Build your own OS using managed languages such as C#, VB.NET, and more!
For instructions on how to install and use Cosmos, please visit the [Cosmos website](http://www.gocosmos.org).
For documentation and technical information, see the [Cosmos Documentation](https://cosmosos.github.io).
+
+If you have questions about how to use Cosmos, want to show off what you have made or have general questions, go check out [Github Discussions](https://github.com/CosmosOS/Cosmos/discussions). If you think you found a bug in Cosmos, please check exising [issues](https://github.com/CosmosOS/Cosmos/issues) first before opening a new one.
+
+We also have a [Discord Server](https://discord.com/invite/kwtBwv6jhD)!
diff --git a/Setup/Cosmos.iss b/Setup/Cosmos.iss
index 3da2499422..de64c94cb2 100644
--- a/Setup/Cosmos.iss
+++ b/Setup/Cosmos.iss
@@ -33,11 +33,11 @@
AppId=CosmosUserKit
AppName=Cosmos User Kit
AppVerName=Cosmos User Kit v{#ChangeSetVersion}
-AppCopyright=Copyright (c) 2007-2019 The Cosmos Project
+AppCopyright=Copyright (c) 2007-2021 The Cosmos Project
AppPublisher=Cosmos Project
-AppPublisherURL=http://www.goCosmos.org/
-AppSupportURL=http://www.goCosmos.org/
-AppUpdatesURL=http://www.goCosmos.org/
+AppPublisherURL=http://www.gocosmos.org/
+AppSupportURL=http://www.gocosmos.org/
+AppUpdatesURL=http://www.gocosmos.org/
AppVersion={#ChangeSetVersion}
SetupMutex=CosmosSetupMutexName,Global\CosmoSetupMutexName
UsePreviousAppDir=false
@@ -71,7 +71,7 @@ LicenseFile=LICENSE.txt
DisableDirPage=no
[Messages]
-SelectDirDesc=If the user installing the Cosmos User Kit is not the admin. Please choose the corresponding AppData/Roaming directory.
+SelectDirDesc=If the user installing the Cosmos User Kit is not the admin, please choose the users AppData/Roaming directory
[Dirs]
Name: {app}; Flags: uninsalwaysuninstall
@@ -105,7 +105,7 @@ Source: ".\Artwork\Cosmos.ico"; DestDir: "{app}"; Flags: ignoreversion uninsremo
; XSharp
Source: ".\Artwork\XSharp\XSharp.ico"; DestDir: "{app}\XSharp\"; Flags: ignoreversion uninsremovereadonly
Source: "..\IL2CPU\source\Cosmos.Core.DebugStub\*.xs"; DestDir: "{app}\XSharp\DebugStub\"; Flags: ignoreversion uninsremovereadonly
-; VMware
+; HyperV
Source: ".\Build\HyperV\*"; DestDir: "{app}\Build\HyperV"; Flags: ignoreversion uninsremovereadonly overwritereadonly recursesubdirs
; VMware
Source: ".\Build\VMware\*"; DestDir: "{app}\Build\VMware"; Flags: ignoreversion uninsremovereadonly overwritereadonly recursesubdirs
diff --git a/Test.sln b/Test.sln
index c443647530..ab389453f9 100644
--- a/Test.sln
+++ b/Test.sln
@@ -166,6 +166,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProcessorTests", "Tests\Ker
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cosmos.Compiler.Tests.BclSystem", "Tests\Kernels\Cosmos.Compiler.Tests.Bcl.System\Cosmos.Compiler.Tests.BclSystem.csproj", "{30D9FA9C-0B4D-40FF-8903-6B9E9C825729}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetworkTest", "Tests\Kernels\NetworkTest\NetworkTest.csproj", "{96855A39-A96B-4BDB-A6AE-29676DFEF637}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -639,6 +641,14 @@ Global
{30D9FA9C-0B4D-40FF-8903-6B9E9C825729}.Release|Any CPU.Build.0 = Release|Any CPU
{30D9FA9C-0B4D-40FF-8903-6B9E9C825729}.Release|x86.ActiveCfg = Release|Any CPU
{30D9FA9C-0B4D-40FF-8903-6B9E9C825729}.Release|x86.Build.0 = Release|Any CPU
+ {96855A39-A96B-4BDB-A6AE-29676DFEF637}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {96855A39-A96B-4BDB-A6AE-29676DFEF637}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {96855A39-A96B-4BDB-A6AE-29676DFEF637}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {96855A39-A96B-4BDB-A6AE-29676DFEF637}.Debug|x86.Build.0 = Debug|Any CPU
+ {96855A39-A96B-4BDB-A6AE-29676DFEF637}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {96855A39-A96B-4BDB-A6AE-29676DFEF637}.Release|Any CPU.Build.0 = Release|Any CPU
+ {96855A39-A96B-4BDB-A6AE-29676DFEF637}.Release|x86.ActiveCfg = Release|Any CPU
+ {96855A39-A96B-4BDB-A6AE-29676DFEF637}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -718,6 +728,7 @@ Global
{BB6A5306-4C7A-4973-A48E-9FE3E683EAEC} = {29EEC029-6A2B-478A-B6E5-D63A91388ABA}
{3F28939D-5E06-44AC-8FC6-ADBBB89AC97B} = {ECEA7778-E786-4317-90B9-A2D4427CB91C}
{30D9FA9C-0B4D-40FF-8903-6B9E9C825729} = {ECEA7778-E786-4317-90B9-A2D4427CB91C}
+ {96855A39-A96B-4BDB-A6AE-29676DFEF637} = {ECEA7778-E786-4317-90B9-A2D4427CB91C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4418C803-277E-448F-A0A0-52788FA215AD}
diff --git a/Tests/Cosmos.System.Tests/VFSManagerTest.cs b/Tests/Cosmos.System.Tests/VFSManagerTest.cs
index fdfd22e82b..835026a5d7 100644
--- a/Tests/Cosmos.System.Tests/VFSManagerTest.cs
+++ b/Tests/Cosmos.System.Tests/VFSManagerTest.cs
@@ -30,7 +30,7 @@ public void Test_Disk_Manager()
{
const string root = @"0:\";
long initialSize = VFSManager.GetTotalSize(root);
- VFSManager.Format(root, "", true);
+ VFSManager.Format("0", "FAT32", true);
Assert.AreEqual(initialSize, VFSManager.GetAvailableFreeSpace(root));
Assert.AreEqual(0, VFSManager.GetDirectoryListing(root).Count);
VFSManager.CreateFile(root + "\\test.txt");
@@ -42,7 +42,7 @@ public void Test_Disk_Manager_Reformating()
{
const string root = @"0:\";
long initialSize = VFSManager.GetTotalSize(root);
- VFSManager.Format(root, "", true);
+ VFSManager.Format("0", "FAT32", true);
Assert.AreEqual(initialSize, VFSManager.GetAvailableFreeSpace(root));
Assert.AreEqual(0, VFSManager.GetDirectoryListing(root).Count);
VFSManager.CreateFile(root + "\\test.txt");
@@ -57,7 +57,7 @@ public void Test_Disk_Manager_Reformating()
Assert.AreEqual(6, lists.Count);
Assert.AreEqual(DirectoryEntryTypeEnum.File, lists[0].mEntryType);
Assert.AreEqual(DirectoryEntryTypeEnum.Directory, lists[5].mEntryType);
- VFSManager.Format(root, "", true);
+ VFSManager.Format("0", "FAT32", true);
Assert.AreEqual(0, VFSManager.GetDirectoryListing(root).Count);
VFSManager.CreateDirectory(root + "\\dir");
VFSManager.CreateFile(root + "\\newfile.txt");
@@ -70,14 +70,14 @@ public void Test_Disk_Manager_Reformating_First_Directories()
{
const string root = @"0:\";
long initialSize = VFSManager.GetTotalSize(root);
- VFSManager.Format(root, "", true);
+ VFSManager.Format("0", "FAT32", true);
Assert.AreEqual(initialSize, VFSManager.GetAvailableFreeSpace(root));
Assert.AreEqual(0, VFSManager.GetDirectoryListing(root).Count);
VFSManager.CreateDirectory(root + "\\SubDir");
VFSManager.CreateFile(root + "\\SubDir\\filet.txt");
Assert.IsNotNull(VFSManager.GetFile(root + "\\SubDir\\filet.txt"));
Assert.AreEqual(1, VFSManager.GetDirectoryListing(root).Count);
- VFSManager.Format(root, "", true);
+ VFSManager.Format("0", "FAT32", true);
Assert.AreEqual(0, VFSManager.GetDirectoryListing(root).Count);
VFSManager.CreateDirectory(root + "\\dir");
Assert.AreEqual(1, VFSManager.GetDirectoryListing(root).Count);
diff --git a/Tests/Cosmos.TestRunner.Full/Cosmos.TestRunner.Full.csproj b/Tests/Cosmos.TestRunner.Full/Cosmos.TestRunner.Full.csproj
index e9ad60390a..aa2fb1739a 100644
--- a/Tests/Cosmos.TestRunner.Full/Cosmos.TestRunner.Full.csproj
+++ b/Tests/Cosmos.TestRunner.Full/Cosmos.TestRunner.Full.csproj
@@ -29,6 +29,7 @@
+
diff --git a/Tests/Cosmos.TestRunner.Full/TestKernelSets.cs b/Tests/Cosmos.TestRunner.Full/TestKernelSets.cs
index 07af2745ba..e988fe34b0 100644
--- a/Tests/Cosmos.TestRunner.Full/TestKernelSets.cs
+++ b/Tests/Cosmos.TestRunner.Full/TestKernelSets.cs
@@ -31,6 +31,7 @@ public static IEnumerable GetStableKernelTypes()
//yield return typeof(KernelGen3.Boot);
yield return typeof(GraphicTest.Kernel);
+ yield return typeof(NetworkTest.Kernel);
/* Please see the notes on the kernel itself before enabling it */
//yield return typeof(ConsoleTest.Kernel);
/* This is a bit slow and works only because ring check is disabled to decide if leave it enabled */
diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/ArrayTests.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/ArrayTests.cs
index e78691211c..667353fb12 100644
--- a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/ArrayTests.cs
+++ b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl.System/System/ArrayTests.cs
@@ -79,7 +79,10 @@ public static void Execute()
error = true;
}
Assert.IsTrue(error && y == 2, "Index out of range exception works correctly for too small positions.");
-
+
+ string[] stringArray = new string[10];
+ stringArray[0] += "asd";
+ Assert.AreEqual(stringArray[0], "asd", "Adding directly to array works");
}
}
}
diff --git a/Tests/Kernels/Cosmos.Kernel.Tests.DiskManager/System.FileSystem/DiskManagerTest.cs b/Tests/Kernels/Cosmos.Kernel.Tests.DiskManager/System.FileSystem/DiskManagerTest.cs
index 68b4d09696..e99dfe682a 100644
--- a/Tests/Kernels/Cosmos.Kernel.Tests.DiskManager/System.FileSystem/DiskManagerTest.cs
+++ b/Tests/Kernels/Cosmos.Kernel.Tests.DiskManager/System.FileSystem/DiskManagerTest.cs
@@ -28,6 +28,24 @@ public static void Execute(Debugger mDebugger)
mDebugger.Send("START TEST: Format");
+ try
+ {
+ MyDrive.Format("FAT16", aQuick: true);
+ }
+ catch (Exception ex)
+ {
+ Assert.IsTrue(ex is NotImplementedException, "Not implemented FAT exception.");
+ }
+
+ try
+ {
+ MyDrive.Format("NTFS", aQuick: true);
+ }
+ catch (Exception ex)
+ {
+ Assert.IsTrue(ex is NotImplementedException, "Not implemented FileSystem exception.");
+ }
+
MyDrive.Format("FAT32", aQuick: true);
mDebugger.Send("Format done testing HDD is really empty");
diff --git a/Tests/Kernels/NetworkTest/Kernel.cs b/Tests/Kernels/NetworkTest/Kernel.cs
new file mode 100644
index 0000000000..1d1a5bfdfb
--- /dev/null
+++ b/Tests/Kernels/NetworkTest/Kernel.cs
@@ -0,0 +1,136 @@
+using Cosmos.HAL;
+using Cosmos.System.Network;
+using Cosmos.System.Network.ARP;
+using Cosmos.System.Network.Config;
+using Cosmos.System.Network.IPv4;
+using Cosmos.System.Network.IPv4.TCP;
+using Cosmos.System.Network.IPv4.UDP;
+using Cosmos.System.Network.IPv4.UDP.DHCP;
+using Cosmos.System.Network.IPv4.UDP.DNS;
+using Cosmos.TestRunner;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Sys = Cosmos.System;
+
+namespace NetworkTest
+{
+ public class Kernel : Sys.Kernel
+ {
+ protected override void BeforeRun()
+ {
+ }
+
+ protected override void Run()
+ {
+ /**
+ * Packet creation and parsing tests
+ **/
+
+ /** Ethernet Packet Parsing Test **/
+ byte[] ethernetPacketData = new byte[]
+ {
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x0C, 0x29, 0xD5, 0xDB, 0x9D, 0x08, 0x00
+ };
+ EthernetPacket ethernetPacket = new EthernetPacket(ethernetPacketData);
+ Equals(ethernetPacketData, ethernetPacket.RawData);
+
+ /** IP Packet Parsing Test **/
+ byte[] ipPacketData = new byte[]
+ {
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x0C, 0x29, 0xD5, 0xDB, 0x9D, 0x08, 0x00, 0x45, 0x00, 0x01, 0x16, 0x00, 0x00, 0x00, 0x00, 0x80, 0x11, 0x39,
+ 0xD8, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF
+ };
+ IPPacket ipPacket = new IPPacket(ipPacketData);
+ Equals(ipPacketData, ipPacket.RawData);
+
+ /** UDP Packet Parsing Test **/
+ byte[] udpPacketData = new byte[]
+ {
+ 0x98, 0xFA, 0x9B, 0xD4, 0xEB, 0x29, 0xD8, 0xCE, 0x3A, 0x89, 0x3E, 0xD9, 0x08, 0x00, 0x45, 0x00, 0x00, 0x22, 0x0C, 0x74, 0x40, 0x00, 0x40, 0x11, 0xAA,
+ 0xBE, 0xC0, 0xA8, 0x01, 0x02, 0xC0, 0xA8, 0x01, 0x46, 0x10, 0x92, 0x10, 0x92, 0x00, 0x0E, 0x37, 0x22, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x21
+ };
+ UDPPacket udpPacket = new UDPPacket(udpPacketData);
+ Equals(udpPacketData, udpPacket.RawData);
+
+ /** DNS Packet Parsing Test **/
+ byte[] dnsPacketData = new byte[]
+ {
+ 0xB8, 0xD9, 0x4D, 0xC1, 0xA5, 0xFC, 0x98, 0xFA, 0x9B, 0xD4, 0xEB, 0x29, 0x08, 0x00, 0x45, 0x00, 0x00, 0x38, 0xC3, 0x1C, 0x00, 0x00, 0x80, 0x11, 0x00,
+ 0x00, 0xC0, 0xA8, 0x01, 0x46, 0xC0, 0xA8, 0x01, 0xFE, 0xF0, 0x66, 0x00, 0x35, 0x00, 0x24, 0x84, 0xCA, 0xD6, 0x80, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x06, 0x67, 0x69, 0x74, 0x74, 0x65, 0x72, 0x03, 0x63, 0x6F, 0x6D, 0x00, 0x00, 0x01, 0x00, 0x01
+ };
+ DNSPacket dnsPacket = new DNSPacket(dnsPacketData);
+ Equals(dnsPacketData, dnsPacket.RawData);
+
+ /** DHCP Packet Parsing Test **/
+ byte[] dhcpPacketData = new byte[]
+ {
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xB8, 0xD9, 0x4D, 0xC1, 0xA5, 0xFC, 0x08, 0x00, 0x45, 0xC0, 0x01, 0x59, 0x46, 0x3F, 0x00, 0x00, 0x40, 0x11, 0x6F,
+ 0xEF, 0xC0, 0xA8, 0x01, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x43, 0x00, 0x44, 0x01, 0x45, 0xD3, 0xC8, 0x02, 0x01, 0x06, 0x00, 0x84, 0xA9, 0x5A, 0x66,
+ 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xA8, 0x01, 0x47, 0xC0, 0xA8, 0x01, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x34, 0xE1, 0x2D, 0xA3, 0x06,
+ 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x63, 0x82, 0x53, 0x63, 0x35, 0x01, 0x05, 0x36, 0x04, 0xC0, 0xA8, 0x01, 0xFE, 0x33, 0x04, 0x00, 0x01, 0x51, 0x80, 0x3A, 0x04, 0x00,
+ 0x00, 0xA8, 0xC0, 0x3B, 0x04, 0x00, 0x01, 0x27, 0x50, 0x1C, 0x04, 0xC0, 0xA8, 0x01, 0xFF, 0x51, 0x12, 0x03, 0xFF, 0xFF, 0x44, 0x45, 0x53, 0x4B, 0x54,
+ 0x4F, 0x50, 0x2D, 0x49, 0x51, 0x48, 0x4A, 0x33, 0x31, 0x43, 0x06, 0x04, 0xC0, 0xA8, 0x01, 0xFE, 0x0F, 0x03, 0x6C, 0x61, 0x6E, 0x03, 0x04, 0xC0, 0xA8,
+ 0x01, 0xFE, 0x01, 0x04, 0xFF, 0xFF, 0xFF, 0x00, 0xFF
+ };
+ DHCPPacket dhcpPacket = new DHCPPacket(dhcpPacketData);
+ Equals(dhcpPacketData, dhcpPacket.RawData);
+
+ /** TCP Packet Parsing Test **/
+ byte[] tcpPacketData = new byte[]
+ {
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x08, 0x00, 0x45, 0x00, 0x00, 0x3C, 0x64, 0x92, 0x40, 0x00, 0x40, 0x06, 0x51,
+ 0xA2, 0xC0, 0xA8, 0x01, 0xD3, 0xC0, 0xA8, 0x01, 0x64, 0xA8, 0xAB, 0x10, 0x92, 0x67, 0x7C, 0xCE, 0x18, 0x00, 0x00, 0x00, 0x00, 0xA0, 0x02, 0x72, 0x10,
+ 0x5F, 0xF0, 0x00, 0x00, 0x02, 0x04, 0x05, 0xB4, 0x04, 0x02, 0x08, 0x0A, 0x58, 0x1A, 0xAA, 0x8A, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x07
+ };
+ TCPPacket tcpPacket = new TCPPacket(tcpPacketData);
+ Equals(tcpPacket.SourcePort, 43179);
+ Equals(tcpPacket.DestinationPort, 4242);
+ Equals(tcpPacket.SequenceNumber, 0x677CCE18);
+ Equals(tcpPacket.AckNumber, 0);
+ Equals(tcpPacket.TCPFlags, Flags.SYN);
+ Equals(tcpPacket.WindowSize, 29200);
+ Equals(tcpPacket.Checksum, 0x5FF0);
+ Equals(tcpPacket.UrgentPointer, 0);
+
+ /** ARP Packet Parsing Test **/
+ byte[] arpPacketData = new byte[]
+ {
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xB8, 0xD9, 0x4D, 0xC1, 0xA5, 0xFC, 0x08, 0x06, 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x01, 0xB8, 0xD9, 0x4D,
+ 0xC1, 0xA5, 0xFC, 0xC0, 0xA8, 0x01, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xA8, 0x01, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ };
+ ARPPacket arpPacket = new ARPPacket(arpPacketData);
+ Equals(arpPacketData, arpPacket.RawData);
+
+ TestController.Completed();
+
+ /**
+ * Clients tests
+ **/
+ var dhcpCLient = new DHCPClient();
+ dhcpCLient.Close();
+
+ var dnsClient = new DnsClient();
+ dnsClient.Close();
+
+ var udpClient = new UdpClient();
+ udpClient.Close();
+
+ var tcpClient = new TcpClient(4242);
+ tcpClient.Close();
+
+ var icmpClient = new ICMPClient();
+ icmpClient.Close();
+ }
+ }
+}
diff --git a/Tests/Kernels/NetworkTest/NetworkTest.csproj b/Tests/Kernels/NetworkTest/NetworkTest.csproj
new file mode 100644
index 0000000000..d6e0d7a18b
--- /dev/null
+++ b/Tests/Kernels/NetworkTest/NetworkTest.csproj
@@ -0,0 +1,14 @@
+
+
+
+ netcoreapp2.0
+ True
+
+
+
+
+
+
+
+
+
diff --git a/Tests/Kernels/SimpleStructsAndArraysTest/Kernel.cs b/Tests/Kernels/SimpleStructsAndArraysTest/Kernel.cs
index b6bb505e62..77c6a8bde1 100644
--- a/Tests/Kernels/SimpleStructsAndArraysTest/Kernel.cs
+++ b/Tests/Kernels/SimpleStructsAndArraysTest/Kernel.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
-
using Cosmos.TestRunner;
using Sys = Cosmos.System;
@@ -82,6 +81,20 @@ private static void TestStep1()
Assert.IsTrue(xItem2.E == 5, "xItem2.E == 5");
}
+ public struct ThreeBytes
+ {
+ public byte A;
+ public byte B;
+ public byte C;
+
+ public ThreeBytes(byte a, byte b, byte c)
+ {
+ A = a;
+ B = b;
+ C = c;
+ }
+ }
+
private class KVPClass
{
public int Key;
@@ -254,6 +267,16 @@ protected static void TestStandardList()
// Assert.IsTrue(xTestMultidimensionalArray[1, 1] == 4, "Index [1, 1] == 4");
//}
+ private void TestRemainder3Structs()
+ {
+ ThreeBytes[] array = new ThreeBytes[1];
+ array[0] = new ThreeBytes(17, 254, 77);
+ Assert.AreEqual(array[0].A, 17, "Three byte struct in array first value read correctly");
+ Assert.AreEqual(array[0].B, 254, "Three byte struct in array second value read correctly");
+ var local = array[0];
+ Assert.AreEqual(local.C, 77, "Three byte struct third value read correctly");
+ }
+
protected override void Run()
{
TestStep1();
@@ -265,6 +288,7 @@ protected override void Run()
//Assert.IsTrue(true, "After TestMultidimensionalArray");
ConstrainedTest.MutateStructTest();
Assert.IsTrue(true, "After MutateTestStruct");
+ TestRemainder3Structs();
TestController.Completed();
}
diff --git a/appveyor.yml b/appveyor.yml
index 5b0497dd2e..eaaad2690e 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,14 +1,23 @@
version: 0.20150918.{build}
-image: Visual Studio 2019 Preview
+image: Visual Studio 2019
configuration: Debug-CI
platform: Any CPU
-shallow_clone: true
clone_folder: c:\Cosmos
+
+
init:
- cmd: |
git clone https://github.com/CosmosOS/IL2CPU.git c:\IL2CPU --depth 1
+install:
+ - ps: |
+ $range = "$env:APPVEYOR_REPO_BRANCH..$env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT"
+ if (-not (git diff --name-only --diff-filter=d $range | Where-Object { $_ -NotMatch ".git*|md|yml|txt$" })) {
+ Write-Host "Only metafiles were modified, skipping CI run."
+ Exit-AppVeyorBuild
+ }
+
build_script:
- cmd: |
rem %APPVEYOR_BUILD_FOLDER%
@@ -37,8 +46,11 @@ test_script:
on_finish:
- ps: |
- $wc = New-Object 'System.Net.WebClient'
- $wc.UploadFile("https://ci.appveyor.com/api/testresults/mstest/$($env:APPVEYOR_JOB_ID)", "c:\Cosmos\TestResult.xml")
+ $tests = "c:\Cosmos\TestResult.xml"
+ if ((Test-Path $tests)) {
+ $wc = New-Object 'System.Net.WebClient'
+ $wc.UploadFile("https://ci.appveyor.com/api/testresults/mstest/$($env:APPVEYOR_JOB_ID)", "c:\Cosmos\TestResult.xml")
+ }
notifications:
- provider: Webhook
@@ -58,3 +70,17 @@ artifacts:
- path: 'artifacts\Debug\nupkg\*.nupkg'
- path: 'artifacts\Debug\VSIX\*.vsix'
- path: 'TestResult.xml'
+
+
+#skip_commits:
+# files:
+# - Docs/
+# - .github/
+# - Artwork/
+# - '**/*.md'
+# - LICENSE.txt
+# - README.txt
+# - .gitignore
+# - source/Archive/
+# - Users/
+
diff --git a/build/Targets/RestoreSources.props b/build/Targets/RestoreSources.props
index 0043818b38..30d4275242 100644
--- a/build/Targets/RestoreSources.props
+++ b/build/Targets/RestoreSources.props
@@ -8,8 +8,7 @@
https://www.myget.org/F/cosmos/api/v3/index.json;
https://ci.appveyor.com/nuget/cosmos-common;
https://ci.appveyor.com/nuget/il2cpu;
- https://ci.appveyor.com/nuget/xsharp;
- https://dotnet.myget.org/F/roslyn-tools/api/v3/index.json
+ https://ci.appveyor.com/nuget/xsharp
$(RestoreSources);$(DefaultPackageOutputPath)
diff --git a/install-VS2019.bat b/install-VS2019.bat
index d85250aefd..f3a36c77ed 100644
--- a/install-VS2019.bat
+++ b/install-VS2019.bat
@@ -1,28 +1,49 @@
-@echo off
-
-cd /D "%~dp0"
-
-if not exist "%ProgramFiles(x86)%" (
- set "ProgramFiles(x86)=%ProgramFiles%"
-)
-
-set "VSWhere=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
-
-:MSBuild
-echo Looking for MSBuild
-for /f "usebackq delims=" %%i in (`^""%VSWhere%" -latest -prerelease -version "[16.0,17.0)" -products * -requires "Microsoft.Component.MSBuild" -property "installationPath"^"`) do (
- set InstallDir=%%i
-)
-
-set "MSBuild=%InstallDir%\MSBuild\Current\Bin\MSBuild.exe"
-
-if not exist "%MSBuild%" (
- echo MSBuild not found. Please make sure Visual Studio 16.0+ is installed.
- pause
- goto:eof
-)
-
-echo Building Builder.sln
-"%MSBuild%" Builder.sln /nologo /maxcpucount /nodeReuse:false /verbosity:minimal /t:Restore;Build
-
-start "Cosmos Builder" "source\Cosmos.Build.Builder\bin\Debug\Cosmos.Build.Builder.exe" "-VSPATH=%InstallDir%" %*
+@echo off
+setlocal
+for /f "tokens=4-5 delims=. " %%i in ('ver') do set VERSION=%%i.%%j
+
+if "%version%" == "6.1" goto seven
+
+:start
+cd /D "%~dp0"
+
+if not exist "%ProgramFiles(x86)%" (
+ set "ProgramFiles(x86)=%ProgramFiles%"
+)
+
+set "VSWhere=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
+
+:MSBuild
+echo Looking for MSBuild
+for /f "usebackq delims=" %%i in (`^""%VSWhere%" -latest -prerelease -version "[16.0,17.0)" -products * -requires "Microsoft.Component.MSBuild" -property "installationPath"^"`) do (
+ set InstallDir=%%i
+)
+
+set "MSBuild=%InstallDir%\MSBuild\Current\Bin\MSBuild.exe"
+
+if not exist "%MSBuild%" (
+ echo MSBuild not found. Please make sure Visual Studio 16.0+ is installed.
+ pause
+ goto:eof
+)
+
+echo Building Builder.sln
+"%MSBuild%" Builder.sln /nologo /maxcpucount /nodeReuse:false /verbosity:minimal /t:Restore;Build
+
+start "Cosmos Builder" "source\Cosmos.Build.Builder\bin\Debug\Cosmos.Build.Builder.exe" "-VSPATH=%InstallDir%" %*
+exit
+
+:seven
+echo Detected Windows 7! Checking for update KB3140245...
+
+for /f "delims=" %%i in ("wmic qfe | find /c ""KB3140245""") do set update=%%i
+if "%update%" == "0" (
+ echo "The update KB3140245 isn't installed on your computer! It is mandatory on Windows 7 to install it in order to build Cosmos."
+ pause
+)
+
+reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v DisabledByDefault /t REG_DWORD /d 0 /f /reg:32
+reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v DisabledByDefault /t REG_DWORD /d 0 /f /reg:64
+reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v Enabled /t REG_DWORD /d 1 /f /reg:32
+reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v Enabled /t REG_DWORD /d 1 /f /reg:64
+goto start
\ No newline at end of file
diff --git a/readme-IT.md b/readme-IT.md
new file mode 100644
index 0000000000..eec341039e
--- /dev/null
+++ b/readme-IT.md
@@ -0,0 +1,9 @@
+# Cosmos
+
+[](https://ci.appveyor.com/project/CosmosOS/cosmos/branch/master)
+
+Cosmos è un "kit di costruzione" per SO. Fai il tuo sistema operativo con linguaggi gestiti come C#, VB.NET, e altri!
+
+Per avere informazioni su come usare Cosmos, visita il [sito web di Cosmos](http://www.gocosmos.org).
+
+Per documentazione e informazioni tecniche, visita la [documentazione di Cosmos](https://cosmosos.github.io).
diff --git a/source/Cosmos.Build.Builder/App.xaml b/source/Cosmos.Build.Builder/App.xaml
index a9e0e5a35c..a5f8938efd 100644
--- a/source/Cosmos.Build.Builder/App.xaml
+++ b/source/Cosmos.Build.Builder/App.xaml
@@ -1,3 +1,13 @@
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:ui="http://schemas.modernwpf.com/2019">
+
+
+
+
+
+
+
+
+
diff --git a/source/Cosmos.Build.Builder/App.xaml.cs b/source/Cosmos.Build.Builder/App.xaml.cs
index 7f2e3eea83..086ba5a69e 100644
--- a/source/Cosmos.Build.Builder/App.xaml.cs
+++ b/source/Cosmos.Build.Builder/App.xaml.cs
@@ -93,6 +93,6 @@ protected override void OnStartup(StartupEventArgs e)
}
private static void ShowErrorMessageBox(string message) =>
- MessageBox.Show(message, "Cosmos Kit Builder", MessageBoxButton.OK, MessageBoxImage.Error);
+ System.Windows.MessageBox.Show(message, "Cosmos Kit Builder", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
diff --git a/source/Cosmos.Build.Builder/BuildTasks/CreateSetupTask.cs b/source/Cosmos.Build.Builder/BuildTasks/CreateSetupTask.cs
index b0a6fabf91..062ee1a76d 100644
--- a/source/Cosmos.Build.Builder/BuildTasks/CreateSetupTask.cs
+++ b/source/Cosmos.Build.Builder/BuildTasks/CreateSetupTask.cs
@@ -41,7 +41,7 @@ protected override string GetExePath()
if (!File.Exists(innoSetupCompilerPath))
{
- throw new InvalidOperationException("Inno Setup installation detected, but the compiler doesn't exist!");
+ throw new InvalidOperationException($"An Inno Setup installation was detected, but no compiler exists at {innoSetupCompilerPath}");
}
return innoSetupCompilerPath;
diff --git a/source/Cosmos.Build.Builder/BuildTasks/ProcessBuildTaskBase.cs b/source/Cosmos.Build.Builder/BuildTasks/ProcessBuildTaskBase.cs
index 781fb25713..8ff0406515 100644
--- a/source/Cosmos.Build.Builder/BuildTasks/ProcessBuildTaskBase.cs
+++ b/source/Cosmos.Build.Builder/BuildTasks/ProcessBuildTaskBase.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
@@ -12,6 +13,7 @@ internal abstract class ProcessBuildTaskBase : IBuildTask
private readonly bool _waitForExit;
private readonly bool _createWindow;
+ private static List Lines = new List();
protected ProcessBuildTaskBase(bool waitForExit, bool createWindow)
{
@@ -26,6 +28,7 @@ public Task RunAsync(ILogger logger)
logger.LogMessage($"\"{exePath}\" {args}");
+ Lines.Clear();
var process = new Process();
var processStartInfo = new ProcessStartInfo(exePath, args);
@@ -62,7 +65,26 @@ private static void WaitForExit(Process process)
if (process.ExitCode != 0)
{
- throw new Exception("The process failed to execute!");
+ if (Lines.Count == 0)
+ {
+ throw new Exception("The process failed to execute!");
+ }
+ else
+ {
+ string error = "";
+ foreach (var item in Lines)
+ {
+ if (item.Contains("error"))
+ {
+ error += item + "\n";
+ }
+ }
+ if (error == "")
+ {
+ error = Lines[Lines.Count - 1];
+ }
+ throw new Exception("The process failed to execute!\nError: \n"+error);
+ }
}
}
@@ -76,7 +98,7 @@ private static async Task ReadOutputAsync(StreamReader reader, ILogger logger)
{
return;
}
-
+ Lines.Add(line);
logger.LogMessage(line);
}
}
diff --git a/source/Cosmos.Build.Builder/Cosmos.Build.Builder.csproj b/source/Cosmos.Build.Builder/Cosmos.Build.Builder.csproj
index c37e2fd0c7..09f03de122 100644
--- a/source/Cosmos.Build.Builder/Cosmos.Build.Builder.csproj
+++ b/source/Cosmos.Build.Builder/Cosmos.Build.Builder.csproj
@@ -23,6 +23,7 @@
+
diff --git a/source/Cosmos.Build.Builder/CosmosBuildDefinition.cs b/source/Cosmos.Build.Builder/CosmosBuildDefinition.cs
index 76695dbc81..bccbff5258 100644
--- a/source/Cosmos.Build.Builder/CosmosBuildDefinition.cs
+++ b/source/Cosmos.Build.Builder/CosmosBuildDefinition.cs
@@ -37,7 +37,8 @@ public CosmosBuildDefinition(
public IEnumerable GetDependencies()
{
- yield return new ReposDependency(_cosmosDir);
+ yield return new ReposDependency(_cosmosDir);
+ yield return new ProperRepoNameDependency(_cosmosDir);
yield return new VisualStudioDependency(_visualStudioInstance);
yield return new VisualStudioWorkloadsDependency(_visualStudioInstance);
yield return new InnoSetupDependency(_innoSetupService);
diff --git a/source/Cosmos.Build.Builder/Dependencies/InnoSetupDependency.cs b/source/Cosmos.Build.Builder/Dependencies/InnoSetupDependency.cs
index 806b605df7..b4dbed86e7 100644
--- a/source/Cosmos.Build.Builder/Dependencies/InnoSetupDependency.cs
+++ b/source/Cosmos.Build.Builder/Dependencies/InnoSetupDependency.cs
@@ -14,6 +14,12 @@ internal class InnoSetupDependency : IDependency
private const string InnoSetupInstallerUrl = "http://www.jrsoftware.org/download.php/is.exe";
public string Name => "Inno Setup";
+ public bool ShouldInstallByDefault => true;
+
+ public string OtherDependencysThatAreMissing
+ {
+ get { return "install " + Name; }
+ }
private readonly IInnoSetupService _innoSetupService;
diff --git a/source/Cosmos.Build.Builder/Dependencies/ProperRepoNameDependency.cs b/source/Cosmos.Build.Builder/Dependencies/ProperRepoNameDependency.cs
new file mode 100644
index 0000000000..d7e886b517
--- /dev/null
+++ b/source/Cosmos.Build.Builder/Dependencies/ProperRepoNameDependency.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace Cosmos.Build.Builder.Dependencies
+{
+ internal class ProperRepoNameDependency : IDependency
+ {
+ public string Name => "Proper Cosmos folder name";
+
+ public bool ShouldInstallByDefault => false;
+
+ public string OtherDependencysThatAreMissing => "rename the directory from where install-VS2019.bat or userkit install.bat is started to Cosmos.";
+ private string CosmosDir;
+
+ public ProperRepoNameDependency(string CosmosDir)
+ {
+ this.CosmosDir = CosmosDir;
+ }
+ public Task InstallAsync(CancellationToken cancellationToken) { throw new NotImplementedException("Installing Proper Cosmos Repository name is not supported"); }
+ public Task IsInstalledAsync(CancellationToken cancellationToken)
+ {
+ var topDir = CosmosDir.Replace(Path.GetDirectoryName(CosmosDir) + Path.DirectorySeparatorChar, "");
+ if (topDir.ToLower() != "cosmos")
+ {
+ return Task.FromResult(false);
+ }
+ else
+ {
+ return Task.FromResult(true);
+ }
+ }
+ }
+}
diff --git a/source/Cosmos.Build.Builder/Dependencies/ReposDependency.cs b/source/Cosmos.Build.Builder/Dependencies/ReposDependency.cs
index 44bfa95736..af43b811ca 100644
--- a/source/Cosmos.Build.Builder/Dependencies/ReposDependency.cs
+++ b/source/Cosmos.Build.Builder/Dependencies/ReposDependency.cs
@@ -13,6 +13,28 @@ namespace Cosmos.Build.Builder.Dependencies
internal class ReposDependency : IDependency
{
public string Name => "Repos: IL2CPU, XSharp and Common";
+ public bool ShouldInstallByDefault => true;
+
+ public string OtherDependencysThatAreMissing
+ {
+ get
+ {
+ string result = "install ";
+ if (!Directory.Exists(Path.GetFullPath(Path.Combine(_cosmosDir, "..", "IL2CPU"))))
+ {
+ result += "IL2CPU Repo, ";
+ }
+ if (!Directory.Exists(Path.GetFullPath(Path.Combine(_cosmosDir, "..", "XSharp"))))
+ {
+ result += "XSharp Repo, ";
+ }
+ if (!Directory.Exists(Path.GetFullPath(Path.Combine(_cosmosDir, "..", "Common"))))
+ {
+ result += "Common Repo";
+ }
+ return result;
+ }
+ }
private readonly string _cosmosDir;
private readonly IEnumerable _repos;
diff --git a/source/Cosmos.Build.Builder/Dependencies/VisualStudioDependency.cs b/source/Cosmos.Build.Builder/Dependencies/VisualStudioDependency.cs
index abdfa7968a..87e684997b 100644
--- a/source/Cosmos.Build.Builder/Dependencies/VisualStudioDependency.cs
+++ b/source/Cosmos.Build.Builder/Dependencies/VisualStudioDependency.cs
@@ -9,11 +9,16 @@ namespace Cosmos.Build.Builder.Dependencies
internal class VisualStudioDependency : IDependency
{
private static readonly Version MinimumVsVersion = new Version(15, 9);
-
+ public bool ShouldInstallByDefault => true;
public string Name => $"Visual Studio {MinimumVsVersion.Major}.{MinimumVsVersion.Minor}+";
+ public string OtherDependencysThatAreMissing
+ {
+ get { return "install " + Name +"+"; }
+ }
private readonly ISetupInstance2 _visualStudioInstance;
+
public VisualStudioDependency(ISetupInstance2 visualStudioInstance)
{
_visualStudioInstance = visualStudioInstance;
diff --git a/source/Cosmos.Build.Builder/Dependencies/VisualStudioWorkloadsDependency.cs b/source/Cosmos.Build.Builder/Dependencies/VisualStudioWorkloadsDependency.cs
index 42a5806748..2a5e9ed301 100644
--- a/source/Cosmos.Build.Builder/Dependencies/VisualStudioWorkloadsDependency.cs
+++ b/source/Cosmos.Build.Builder/Dependencies/VisualStudioWorkloadsDependency.cs
@@ -17,9 +17,33 @@ internal class VisualStudioWorkloadsDependency : IDependency
NetCoreToolsWorkload,
VisualStudioExtensionsWorkload
};
-
+ public bool ShouldInstallByDefault => false;
public string Name => "Visual Studio Workloads";
+ public string OtherDependencysThatAreMissing
+ {
+ get
+ {
+ var missingPackages = ((string[])RequiredPackages.Clone()).ToList();
+ foreach (var item in RequiredPackages)
+ {
+ if (IsPackageInstalled(item))
+ {
+ missingPackages.Remove(item);
+ }
+ }
+
+ //Add the missing packages together
+ string missingPackages_proper = "install ";
+ foreach (var item in missingPackages)
+ {
+ missingPackages_proper += GetProperName(item) + ", ";
+ }
+
+ return missingPackages_proper;
+ }
+ }
+
private readonly ISetupInstance2 _visualStudioInstance;
public VisualStudioWorkloadsDependency(ISetupInstance2 visualStudioInstance)
@@ -32,7 +56,19 @@ public Task IsInstalledAsync(CancellationToken cancellationToken)
var installedPackages = _visualStudioInstance.GetPackages();
return Task.FromResult(RequiredPackages.All(p => IsPackageInstalled(p)));
}
+ private string GetProperName(string packageId)
+ {
+ if (packageId == NetCoreToolsWorkload)
+ {
+ return ".NET Core cross-platform development";
+ }
+ else if (packageId == VisualStudioExtensionsWorkload)
+ {
+ return "Visual Studio Extension development";
+ }
+ return "Unknown Workload: " + packageId;
+ }
public async Task InstallAsync(CancellationToken cancellationToken)
{
var vsInstallerPath = Environment.ExpandEnvironmentVariables(
diff --git a/source/Cosmos.Build.Builder/IDependency.cs b/source/Cosmos.Build.Builder/IDependency.cs
index e881c1a462..3d6549b84c 100644
--- a/source/Cosmos.Build.Builder/IDependency.cs
+++ b/source/Cosmos.Build.Builder/IDependency.cs
@@ -6,7 +6,9 @@ namespace Cosmos.Build.Builder
internal interface IDependency
{
string Name { get; }
+ bool ShouldInstallByDefault { get; }
+ string OtherDependencysThatAreMissing { get; }
Task IsInstalledAsync(CancellationToken cancellationToken);
Task InstallAsync(CancellationToken cancellationToken);
}
diff --git a/source/Cosmos.Build.Builder/ViewModels/DependencyInstallationDialogViewModel.cs b/source/Cosmos.Build.Builder/ViewModels/DependencyInstallationDialogViewModel.cs
index 8c63e41ed5..a5d1d0ce42 100644
--- a/source/Cosmos.Build.Builder/ViewModels/DependencyInstallationDialogViewModel.cs
+++ b/source/Cosmos.Build.Builder/ViewModels/DependencyInstallationDialogViewModel.cs
@@ -70,6 +70,10 @@ public DependencyInstallationDialogViewModel(IDependency dependency)
public void Dispose()
{
+ if (_installTask == null)
+ {
+ return;
+ }
_installTask.Dispose();
_installTaskCancellationTokenSource.Dispose();
}
diff --git a/source/Cosmos.Build.Builder/ViewModels/MainWindowViewModel.cs b/source/Cosmos.Build.Builder/ViewModels/MainWindowViewModel.cs
index 05836967df..c841c1f15b 100644
--- a/source/Cosmos.Build.Builder/ViewModels/MainWindowViewModel.cs
+++ b/source/Cosmos.Build.Builder/ViewModels/MainWindowViewModel.cs
@@ -62,7 +62,7 @@ public MainWindowViewModel(
CopyCommand = new RelayCommand(CopyLogToClipboard);
CloseWhenCompleted = true;
-
+
_logger = new MainWindowLogger(this);
_buildTask = BuildAsync();
@@ -74,7 +74,7 @@ private string BuildLog()
{
var log = @"
========================================
- Builder Log
+ Build Log
========================================
";
@@ -95,10 +95,9 @@ Builder Log
private async Task BuildAsync()
{
+ _logger.NewSection("Checking Dependencies...");
try
{
- _logger.NewSection("Checking Dependencies");
-
foreach (var dependency in _buildDefinition.GetDependencies())
{
if (await dependency.IsInstalledAsync(CancellationToken.None).ConfigureAwait(false))
@@ -107,20 +106,40 @@ private async Task BuildAsync()
}
else
{
- _logger.LogMessage($"{dependency.Name} not found.");
+ _logger.LogMessage($"{dependency.Name} was not found. Install {dependency.OtherDependencysThatAreMissing.TrimEnd(',')}");
- using (var viewModel = new DependencyInstallationDialogViewModel(dependency))
+ if (dependency.ShouldInstallByDefault)
{
- _dependencyInstallationDialogService.ShowDialog(viewModel);
-
- if (!viewModel.InstallationSucceeded)
+ using (var viewModel = new DependencyInstallationDialogViewModel(dependency))
{
- throw new Exception($"Dependency installation failed! Dependency name: {dependency.Name}");
+ _dependencyInstallationDialogService.ShowDialog(viewModel);
+
+ if (!viewModel.InstallationSucceeded)
+ {
+ throw new Exception($"Dependency installation failed! Dependency name: {dependency.Name}");
+ }
}
}
+ else
+ {
+ Views.MessageBox.Show($"{dependency.Name} is not installed. Please {dependency.OtherDependencysThatAreMissing}");
+ _logger.SetError();
+ _logger.NewSection("Error");
+ _logger.LogMessage($"{dependency.Name} not found.");
+ _logger.SetError();
+ return;
+ }
}
}
+ }
+ catch (Exception e)
+ {
+ OnError("Error while installing dependencies: " + e.Message);
+ return;
+ }
+ try
+ {
foreach (var buildTask in _buildDefinition.GetBuildTasks())
{
_logger.NewSection(buildTask.Name);
@@ -130,11 +149,8 @@ private async Task BuildAsync()
}
catch (Exception e)
{
- _logger.SetError();
-
- _logger.NewSection("Error");
- _logger.LogMessage(e.ToString());
- _logger.SetError();
+ OnError(e.Message);
+ return;
}
await Task.Delay(5000).ConfigureAwait(false);
@@ -151,5 +167,13 @@ private async Task BuildAsync()
}
}
}
+ public void OnError(string message)
+ {
+ _logger.SetError();
+
+ _logger.NewSection("Error");
+ _logger.LogMessage(message);
+ _logger.SetError();
+ }
}
}
diff --git a/source/Cosmos.Build.Builder/Views/DependencyInstallationDialog.xaml b/source/Cosmos.Build.Builder/Views/DependencyInstallationDialog.xaml
index 943571d54a..b9c00eb45f 100644
--- a/source/Cosmos.Build.Builder/Views/DependencyInstallationDialog.xaml
+++ b/source/Cosmos.Build.Builder/Views/DependencyInstallationDialog.xaml
@@ -10,11 +10,13 @@
ShowInTaskbar="False"
SizeToContent="WidthAndHeight"
Title="Cosmos Kit Builder"
- WindowStartupLocation="CenterOwner">
+ WindowStartupLocation="CenterOwner"
+ xmlns:ui="http://schemas.modernwpf.com/2019"
+ ui:WindowHelper.UseModernWindowStyle="True">
-
diff --git a/source/Cosmos.Build.Builder/Views/MessageBox.xaml b/source/Cosmos.Build.Builder/Views/MessageBox.xaml
new file mode 100644
index 0000000000..6f22570242
--- /dev/null
+++ b/source/Cosmos.Build.Builder/Views/MessageBox.xaml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/source/Cosmos.Build.Builder/Views/MessageBox.xaml.cs b/source/Cosmos.Build.Builder/Views/MessageBox.xaml.cs
new file mode 100644
index 0000000000..cc52216f69
--- /dev/null
+++ b/source/Cosmos.Build.Builder/Views/MessageBox.xaml.cs
@@ -0,0 +1,27 @@
+using System.Windows;
+
+namespace Cosmos.Build.Builder.Views
+{
+ public partial class MessageBox : Window
+ {
+ public MessageBox(string Content)
+ {
+ InitializeComponent();
+ lblMain.Text = Content;
+ }
+
+ public static void Show(string Content)
+ {
+ var window = new MessageBox(Content);
+ //this workarounds a bug that when the main window is minimized then brought to front, the message box is no longer visible
+ window.Topmost = true;
+ window.ShowDialog();
+ }
+
+ private void Button_Click(object sender, RoutedEventArgs e)
+ {
+ Topmost = false;
+ Close();
+ }
+ }
+}
diff --git a/source/Cosmos.Build.Builder/Views/VisualStudioInstanceDialog.xaml b/source/Cosmos.Build.Builder/Views/VisualStudioInstanceDialog.xaml
index 7763fc5c8e..55e4f53af2 100644
--- a/source/Cosmos.Build.Builder/Views/VisualStudioInstanceDialog.xaml
+++ b/source/Cosmos.Build.Builder/Views/VisualStudioInstanceDialog.xaml
@@ -4,16 +4,18 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:ui="http://schemas.modernwpf.com/2019"
mc:Ignorable="d"
Icon="/Cosmos.Build.Builder;component/Resources/Cosmos.ico"
ResizeMode="NoResize"
SizeToContent="WidthAndHeight"
Title="Choose Visual Studio Instance"
- WindowStartupLocation="CenterOwner">
+ WindowStartupLocation="CenterOwner"
+ ui:WindowHelper.UseModernWindowStyle="True">
-