I've written a feature that I want to unit test. I've been following Jason Weimann's video. (I haven't found a tutorial for VS Code, so I went with one on Visual Studio.) Basically, it says:
In Unity, go to Window -> General -> Test Runner.
Create an EditMode test assembly folder (creates an asmdef file by itself).
Create an assembly definition file in the Scripts folder, and reference it from the EditMode asmdef.
As soon as I add the scripts asmdef file, I get a couple of CS0234/CS0246 errors, for example
The type or namespace name 'InputSystem' does not exist in the namespace 'UnityEngine'
The type or namespace name 'IInputActionCollection' could not be found
Which are all in the class generated by the new input system. Oddly enough, VS Code doesn't mention a word about these errors.
There are also 2 warnings, both saying "Assembly for Assembly Definition File X will not compile, because it has no scripts associated with it." First one is about the test asmdef, second one about the scripts asmdef.
I thought I'd fix the warnings first. I found this link which says the issue is fixed with Unity 2020.1.3f1, so I upgraded the project version to 2020.1.6f1. Poof, warnings are gone - but not the errors.
I also tried what this post said - which is related to the first error above. No success with it.
If that helps, I already have installed the unity package Input System 1.0.0
Where should I go from here?
Related
I have set up a local Azure Function project in VSCode as per the instructions here https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-csharp?tabs=in-process
The default templated function that is created works when I run it in VSCode, but I am seeing reference errors in the VSCode editor as per screen shot.
When I go to the definition of the HttpRequest class for example, I see no Query method.
How can I fix these?
The options I selected were C#, .NET 6, HTTP Trigger, Anonymous, Add to Workspace
I have installed .NET 6 SDK, Azure Function Tools, C# extension, Azure function extension.
Thank you
Edit:
The exact message I get when I mouseover one of the reference errors is
The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13 ...
I ran into the same problem today. I have the C# extension installed in VS Code and noticed this line in the extension description:
When I set that flag to true (and restarted OmniSharp or VSCode), the issue went away :)
I tried to reproduce the issue:
Firstly, I have selected my workspace folder from the VSCode,
Created the function project using func init command in the VS Code terminal.
Create the function using func new command in the terminal, selected Http Trigger from the dropdown display of triggers and given the function name as Hello.
Click on the Hello.cs file, then you will get a side dialog box on the bottom of the same VS Code window.
Click on Restore.
OR
If you get two dialog boxes, then click on Restore and Yes so that it will restore the NuGet packages and functions dependencies required for that environment.
You can also see in the output terminal opens immediately after clicking restore option:
After adding those, you will get clean error-free UI like below:
Note:
If you have written the class/function manually in the code, please check that you renamed the Function class name both in the code as well in the file explorer like:
Updated Answer:
As per your edits and comments, I also installed .Net SDK Version 6 and checked the project in VS Code and I got the restore dialog box again with that red squiggly lines. After clicking on restore option, all red squiggly lines went out and this is the Proof-Of-Concept:
I did get this resolved, though I am not sure exactly how/ why, so i'll just post what I did in case it helps someone else.
Firstly I removed the Microsoft C# extension and re-installed it. I dont think this had any effect and it didnt seem to fix the issue, I am just mentioning it as I will mention everything I did.
When I googled the error that is in my Edit above The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13 I found some references to the MS Build tool/ library shipped with Visual Studio (not VS Code) in regards to .NET 6 and how the .NET 6 requires a certain version of the Build utility.
The recommendation was to upgrade Visual Studio (not VSCode), which I already had installed and that would update the MS Build.
I didnt really understand quite a bit of what I read, but I updated my install of Visual Studio Community 2019 in the hope that it would update MS Build and it seems to have worked.
I expect there is another way to do this without Visual Studio, but I chose this way as I had it installed anyway.
One last thing was I went to bed and had a sleep, then checked it again in the morning.
Cant really say for sure which of the three things worked :)
In the C# VS2010 Solution I'm working in, there is a namespace called: EBI.Core.Base.Constant.EBISystem
That namespace's DLL is referenced as a Project (i.e. a project native to the solution,) in a different project in the same solution.
VS shows error saying that: The type of namespace Base does not exist. This is true, it does not exist because the actual name is the full namespace name above.
When I remove the project reference and add it back in, the error goes away and the full namespace name is recognized, but as soon as I build, the error comes back. Same thing happens if I close the solution and re-open it, no error, until I build.
This error seems to be happening only on my dev machine and no one else's with the same exact solution.
I looked at my GAC and there's no stray or missing dll there. I have closed and restarted the solution, I have restarted my machine to no avail. Also checked project build dependencies and they are correct. Unloaded and released the project, still the same thing.
Both the project being worked on and the referenced project are .Net 3.5.
Wondering if anyone has any suggestions. I've tried everything here: Getting "type or namespace name could not be found" but everything seems ok?
Use the same target framework version for your project and the library "EBI.Core.Base.Constant.EBISystem"
I've added a Fakes assembly to my Visual Studio 2012 unit test project, corresponding to my application project (the System Under Test), as described in Peter Provost's article. However, the project will no longer build, on account of an unresolved type reference in the generated Fakes code:
The type or namespace name 'FieldDefinition' does not exist in the namespace 'bc::ProductStudio' (are you missing an assembly reference?)
[C:\Users\arvek\Projects\Project\Project.Tests\obj\Debug\Fakes\bc\f.csproj]
C:\Users\arvek\Projects\Project\Project.Tests\f.cs
What's going wrong here? From what I know, this is supposed to just work, so it would seem to me there's a bug in the Fakes facilities.
This bug is present in VS2013 as well. Link to MSDN bug.
Work Around: Delete file .messages from FakeAssemblies folder.
The error is most likely due to bug in Fakes triggered by the faked assembly. I've submitted the issue to Microsoft.
One option that may help you diagnose the issue is turning on diagnostics for you fakes. On your .fakes file.
<Fakes xmlns="http://schemas.microsoft.com/fakes/2011" Diagnostic="true" Verbosity="Noisy">
Also, make sure that your "MSBuild project build output verbosity" is set to Diagnostic. You can find this in Tools -> Options -> Projects and Solutions -> Build and Run.
Rebuild you test project and now your output window should be full of info including any failures for Fakes
Deleting Fakes folder will resolve this issue.
You're not going to believe this, but I was able to get the fakes working again by simply adding a new line to the file, removing that new line, and then saving what is effectively an unmodified file. After the next build everything was fine.
Things that make you go... hmm...
I would first like to admit that I am an extremely novice developer, so I'm doing my best to give all of the relevant information to make this question answerable:
So I'm trying to do some unit tests for NxBRE before I start attempting further work with the engine. I've downloaded both NxBRE and NUnit (version 3.2 and 2.6 respectively) and I've tested NUnit to make sure that it is working properly using a simple example that I could post here, but seems irrelevant to do so. What's important was that I was easily able to reference the nunit.framework.dll in the example, and the tested attributes compiled and the GUI ran the tests perfectly. I'm using SharpDevelop by the way.
I then opened up the provided NxBRE solution, which has two projects (NxBRE and NxBRE-UnitTest), added the same reference in the Unit-Test project to the nunit.framework.dll, and attempted to build the solution. I got a compiler error (along with the host of associated errors) stating that:
CS0246: The type or namespace name 'nunit' could not be found (are you missing a using directive or an assembly reference?)
Well, I was pretty sure I wasn't missing either, so I double checked the reference, and it seemed good (in that I re-added it in the way that I had for my test example). I even manually copied the .dll to the directories that were being accessed. I don't think it was an issue with NUnit itself, because I went back to my crafted example and it still ran fine.
Do you have any suggestions for trouble-shooting ideas or techniques that I should try?
I examined the .csproj file of the NxBRE 3 test project, and there is no directory path associated with nunit.framework.
In other words, the test project expects NUnit to be installed in the Global Assembly Cache. Could it be that you have not installed NUnit via its .msi file but rather unpacked it from a .zip file?
My recommendation is that you remove the nunit.framework reference from the test project and then add the reference again by browsing for the actual DLL file in the file system.
I'm trying to recreate a solution that had multiple projects in it (only the cs, aspx, etc, remain). When I create a blank solution and blank project files and start re-adding things, I receive the following compiler errors numerous times:
The type or namespace name 'Activation' could not be found (are you missing a using directive or an assembly reference?)
The Activation class is defined in a Activation.cs file that is in a sub folder to the cs file that is using it. I've added and included the files in the project...
The website currently works in production as is, so I'm wondering what type of reference I need...
The following is the structure
Solution
Project1
FileUsingActivation.cs
Folder1
Activation.cs (which contains the class being used in FileUsingActivation.cs that the compiler is complaining about
Edit 1: Just a note that Visual Studio can't resolve the class name, meaning it currently has a squiggly line under the class1 : Activation (Activation portion). But the file is definately included in the project, it's just under another sub folder... I mean I know it won't compile because VS can't resolve the name, but I'm wondering why....
Edit 2: If I add the file to the root of the project, the class name highlights blue, the squiggly goes away as does the error.... so I can't keep the existing folder structure in the project for some reason????
long shot: check for compiler conditionals (like #if some_condition/.../#endif);
Your build configurations might have contained them.
Also, check that the build action is 'compile' for the build configuration that you're trying to build.
Build configurations: MSDN
Conditional Compilation: MSDN
Could be a few things, but given your context...
Are you using .NET 4/VS 2010? The default "Target Framework" for projects is .NET Framework 4 Client Profile, but if you are referencing another project that is the full .NET Framework 4 you'll get this un-informative build error.
To fix this, right-click on your project, click "Properties", and under the "Application" tab set the target framework to .NET Framework 4 (and not .NET Framework 4 Client Profile).
EDIT: For anyone else who stumbles on this question/answer, the above solution will work for you if your classes appear to be included/working while editing (highlighted light blue, etc), and you can right-click "Go-to Definition" for it, but then it gives build errors as if it could not be resolved.