将 VS Pro 2022 更新到最新可用版本 17.4.0 后,我无法再在我的 VS 解决方案之一中运行任何 NUnit 测试。测试资源管理器正确显示测试列表,但是,没有一个测试实际上正在执行。我可以看到一些警告正在累积,这是打印输出:
========== Starting test discovery ==========
Test project TestHelpers does not reference any .NET NuGet adapter. Test
discovery or execution might not work for this project.
It's recommended to reference NuGet test adapters in each test project in the solution.
Test project TestHelper.NUnitAssert does not reference any .NET NuGet
adapter. Test discovery or execution might not work for this project.
It's recommended to reference NuGet test adapters in each test …Run Code Online (Sandbox Code Playgroud) 我试图在 VS Code 中调试一个简单的“Hello world”应用程序,但是,当我按 Ctrl + F5 时,它给了我以下错误:
如果我手动更改 launch.json 中的路径:
${workspaceFolder}/bin/Debug/insert-target-framework-here/insert-project-name-here.dll
Run Code Online (Sandbox Code Playgroud)
到:
"${workspaceFolder}/bin/Debug/netcoreapp2.1/test.dll"
Run Code Online (Sandbox Code Playgroud)
它确实有效,但是在没有我手动输入路径的情况下它可以正常工作之前。另外,我注意到 VS Code 不再像以前那样要求重建资产:
到目前为止,我已经尝试了以下方法:
卸载 VS Code,然后是 .NET Core 2.1,从 %USER%\.vscode\ 中删除 VS Code 扩展文件夹,重新安装 VS Code,然后是 .NET Core 2.1,然后是 C# 扩展(C# for Visual Studio Code(供电)由 OmniSharp))。
当 VS Code 启动时,它确实成功下载了“OmniSharp”包,但是当我打开 C# 文件时仍然没有提示重建资产。调试给出了与以前相同的问题。
这是launch.json:
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/<insert-target-framework-here>/<insert-project-name-here>.dll",
"args": [],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
}
Run Code Online (Sandbox Code Playgroud)
和tasks.json: …
我试图使用TCP将json从C#服务器传递到Java服务器,问题是Java服务器第一次似乎收到一个空的json.第二次以及之后它工作正常,请参见下面的输出.欢迎任何想法或建议,谢谢.
输出:
Starting server...
Waiting for a connection..
Connected!
Reading...
Received empty object
Received:
Connected!
Reading...
Received: "Request:gethotellist"
Connected!
Reading...
Received: "Request:gethotellist"
Run Code Online (Sandbox Code Playgroud)
以下是用于发送json的C#代码段:
public void GetHotelList()
{
TcpClient clientSocket = new TcpClient();
clientSocket.Connect("127.0.0.1", 6767);
NetworkStream ns = clientSocket.GetStream();
string jsonRequest = "Request:gethotellist";
string jsonToSend = JsonConvert.SerializeObject(jsonRequest);
byte[] dataBytes = Encoding.UTF8.GetBytes(jsonToSend);
ns.Write(dataBytes, 0, dataBytes.Length);
ns.Close();
}
Run Code Online (Sandbox Code Playgroud)
Java服务器:
public class JHotelServer
{
public static void main(String[] args) throws IOException
{
final int PORT = 6767;
System.out.println("Starting server...");
@SuppressWarnings("resource")
ServerSocket welcomeSocket = new …Run Code Online (Sandbox Code Playgroud) 我想在我的应用中使用FCM,但是在添加了最新的firebase-messaging依赖项之后:
implementation 'com.google.firebase:firebase-messaging:18.0.0'
Run Code Online (Sandbox Code Playgroud)
构建项目时,在编译器中出现以下错误:
error: cannot find symbol class GetTokenResult
Run Code Online (Sandbox Code Playgroud)
该错误来自于我用来捕获用户令牌的FirebaseUserInterceptor,它工作得很好。但是,添加消息传递依赖性后,“ GetTokenResult”和“ getToken()”似乎都无法识别,因此引发了上述错误。
码:
import android.util.Log;
import com.google.android.gms.tasks.Task;
import com.google.android.gms.tasks.Tasks;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.auth.GetTokenResult;
import java.io.IOException;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
public class FirebaseUserInterceptor implements Interceptor {
private static final String X_FIREBASE_ID_TOKEN = "firebaseUserId";
private static final String TAG = "FirebaseUserInterceptor";
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
try {
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if (user == null) {
Log.d(TAG, …Run Code Online (Sandbox Code Playgroud)