Skip to content

Commit

Permalink
Initial .NET8 Upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminZehowlt committed Nov 14, 2023
1 parent 7bb5c8e commit 4c6f4df
Show file tree
Hide file tree
Showing 14 changed files with 506 additions and 639 deletions.
5 changes: 2 additions & 3 deletions Dotnet/AppApi/AppApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using System.Text;
using System.Threading;
using System.Windows.Forms;
using Windows.UI.Notifications;
using CefSharp;
using librsync.net;
using Microsoft.Win32;
Expand Down Expand Up @@ -180,7 +179,7 @@ public string GetImage(string url, string fileId, string version)
/// <param name="BoldText">The bold text to display in the notification.</param>
/// <param name="Text">The optional text to display in the notification.</param>
/// <param name="Image">The optional image to display in the notification.</param>
public void DesktopNotification(string BoldText, string Text = "", string Image = "")
/*public void DesktopNotification(string BoldText, string Text = "", string Image = "")
{
var toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastImageAndText02);
var stringElements = toastXml.GetElementsByTagName("text");
Expand All @@ -196,7 +195,7 @@ public void DesktopNotification(string BoldText, string Text = "", string Image
imageElements[0].Attributes.GetNamedItem("src").NodeValue = imagePath;
var toast = new ToastNotification(toastXml);
ToastNotificationManager.CreateToastNotifier("VRCX").Show(toast);
}
}*/

/// <summary>
/// Restarts the VRCX application for an update by launching a new process with the "/Upgrade" argument and exiting the current process.
Expand Down
2 changes: 1 addition & 1 deletion Dotnet/Cef/CefService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ internal void Init()
cefSettings.CefCommandLineArgs["remote-allow-origins"] = "*";
}

CefSharpSettings.WcfEnabled = true; // TOOD: REMOVE THIS LINE YO (needed for synchronous configRepository)
//CefSharpSettings.WcfEnabled = true; // TOOD: REMOVE THIS LINE YO (needed for synchronous configRepository)
CefSharpSettings.ShutdownOnExit = false;

if (Cef.Initialize(cefSettings) == false)
Expand Down
2 changes: 1 addition & 1 deletion Dotnet/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private void MainForm_Load(object sender, System.EventArgs e)
if ("true".Equals(VRCXStorage.Instance.Get("VRCX_StartAsMinimizedState")) &&
"true".Equals(VRCXStorage.Instance.Get("VRCX_CloseToTray")))
{
BeginInvoke(new MethodInvoker(Hide));
BeginInvoke(Hide);
}
else
{
Expand Down
7 changes: 4 additions & 3 deletions Dotnet/Overlay/OffScreenBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using System;
using System.Runtime.InteropServices;
using System.Threading;
using Range = CefSharp.Structs.Range;

namespace VRCX
{
Expand Down Expand Up @@ -87,7 +88,7 @@ public void RenderToTexture(Texture2D texture)
var rowPitch = dataBox.RowPitch;
if (pitch == rowPitch)
{
WinApi.CopyMemory(
WinApi.RtlCopyMemory(
destinationPtr,
sourcePtr,
(uint)(_width * _height * 4)
Expand All @@ -97,7 +98,7 @@ public void RenderToTexture(Texture2D texture)
{
for (var y = _height; y > 0; --y)
{
WinApi.CopyMemory(
WinApi.RtlCopyMemory(
destinationPtr,
sourcePtr,
(uint)pitch
Expand Down Expand Up @@ -168,7 +169,7 @@ void IRenderHandler.OnPaint(PaintElementType type, Rect dirtyRect, IntPtr buffer
);
}

WinApi.CopyMemory(
WinApi.RtlCopyMemory(
_paintBuffer.AddrOfPinnedObject(),
buffer,
(uint)(width * height * 4)
Expand Down
10 changes: 5 additions & 5 deletions Dotnet/Overlay/VRCXVR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,11 @@ private void ThreadLoop()
}
}

_browser2.Dispose();
_browser1.Dispose();
_texture2.Dispose();
_texture1.Dispose();
_device.Dispose();
_browser2?.Dispose();
_browser1?.Dispose();
_texture2?.Dispose();
_texture1?.Dispose();
_device?.Dispose();
}

public void SetActive(bool active, bool hmdOverlay, bool wristOverlay, bool menuButton, int overlayHand)
Expand Down
16 changes: 8 additions & 8 deletions Dotnet/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ public static class Util
public static void ApplyJavascriptBindings(IJavascriptObjectRepository repository)
{
repository.NameConverter = null;
repository.Register("AppApi", AppApi.Instance, true);
repository.Register("SharedVariable", SharedVariable.Instance, false);
repository.Register("WebApi", WebApi.Instance, true);
repository.Register("VRCXStorage", VRCXStorage.Instance, true);
repository.Register("SQLite", SQLiteLegacy.Instance, true);
repository.Register("LogWatcher", LogWatcher.Instance, true);
repository.Register("Discord", Discord.Instance, true);
repository.Register("AssetBundleCacher", AssetBundleCacher.Instance, true);
repository.Register("AppApi", AppApi.Instance);
repository.Register("SharedVariable", SharedVariable.Instance);
repository.Register("WebApi", WebApi.Instance);
repository.Register("VRCXStorage", VRCXStorage.Instance);
repository.Register("SQLite", SQLiteLegacy.Instance);
repository.Register("LogWatcher", LogWatcher.Instance);
repository.Register("Discord", Discord.Instance);
repository.Register("AssetBundleCacher", AssetBundleCacher.Instance);
}
}
}
14 changes: 10 additions & 4 deletions Dotnet/WebApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ internal void LoadCookies()
{
using (var stream = new MemoryStream(Convert.FromBase64String((string)values[0])))
{
_cookieContainer = (CookieContainer)new BinaryFormatter().Deserialize(stream);
_cookieContainer = new CookieContainer();
_cookieContainer.Add(System.Text.Json.JsonSerializer.Deserialize<CookieCollection>(stream));
//_cookieContainer = (CookieContainer)new BinaryFormatter().Deserialize(stream);
}
}
catch
Expand All @@ -94,7 +96,8 @@ internal void SaveCookies()
{
using (var memoryStream = new MemoryStream())
{
new BinaryFormatter().Serialize(memoryStream, _cookieContainer);
System.Text.Json.JsonSerializer.Serialize(memoryStream, _cookieContainer.GetAllCookies());
//new BinaryFormatter().Serialize(memoryStream, _cookieContainer);
SQLiteLegacy.Instance.ExecuteNonQuery(
"INSERT OR REPLACE INTO `cookies` (`key`, `value`) VALUES (@key, @value)",
new Dictionary<string, object>() {
Expand All @@ -116,7 +119,8 @@ public string GetCookies()

using (var memoryStream = new MemoryStream())
{
new BinaryFormatter().Serialize(memoryStream, _cookieContainer);
System.Text.Json.JsonSerializer.Serialize(memoryStream, _cookieContainer.GetAllCookies());
//new BinaryFormatter().Serialize(memoryStream, _cookieContainer);
return Convert.ToBase64String(memoryStream.ToArray());
}
}
Expand All @@ -125,7 +129,9 @@ public void SetCookies(string cookies)
{
using (var stream = new MemoryStream(Convert.FromBase64String(cookies)))
{
_cookieContainer = (CookieContainer)new BinaryFormatter().Deserialize(stream);
//_cookieContainer = (CookieContainer)new BinaryFormatter().Deserialize(stream);
_cookieContainer = new CookieContainer();
_cookieContainer.Add(System.Text.Json.JsonSerializer.Deserialize<CookieCollection>(stream));
}

_cookieDirty = true; // force cookies to be saved for lastUserLoggedIn
Expand Down
2 changes: 1 addition & 1 deletion Dotnet/WinApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace VRCX
public static class WinApi
{
[DllImport("kernel32.dll", SetLastError = false)]
public static extern void CopyMemory(IntPtr destination, IntPtr source, uint length);
public static extern void RtlCopyMemory(IntPtr destination, IntPtr source, uint length);

[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
Expand Down
25 changes: 0 additions & 25 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,10 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해
// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면
// 이러한 특성 값을 변경하세요.
[assembly: AssemblyTitle("VRCX")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VRCX")]
[assembly: AssemblyCopyright("vrcx-team, pypy, natsumi")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에
// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면
// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요.
[assembly: ComVisible(false)]

// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다.
[assembly: Guid("d9f66f2e-3ed9-4d53-a6ac-adcc1513562a")]

// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다.
//
// 주 버전
// 부 버전
// 빌드 번호
// 수정 버전
//
// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호가 자동으로
// 지정되도록 할 수 있습니다.
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Loading

0 comments on commit 4c6f4df

Please sign in to comment.