Antlr4 target C# error - c#

I have setup my C# project to use the Antlr4 build targets and extension for compiling the g4 grammer. However, when I build I am getting the following errors. Any thoughts?
Error 1 The name 'HIDDEN' does not exist in the current context C:\gNOSIS\Oracle\Software\oracle\oracle\obj\x64\Debug\Verilog2001Lexer.cs 131 22 oracle
Error 2 The name 'HIDDEN' does not exist in the current context C:\gNOSIS\Oracle\Software\oracle\oracle\obj\x64\Debug\Verilog2001Lexer.cs 136 22 oracle
Error 4 The name 'HIDDEN' does not exist in the current context C:\gNOSIS\Oracle\Software\oracle\oracle\obj\x64\Debug\Verilog2001Lexer.cs 145 22 oracle
Error 5 'Antlr4.Runtime.ICharStream' does not contain a definition for 'LA' and no extension method 'LA' accepting a first argument of type 'Antlr4.Runtime.ICharStream' could be found (are you missing a using directive or an assembly reference?) C:\gNOSIS\Oracle\Software\oracle\oracle\obj\x64\Debug\Verilog2001Lexer.cs 156 25 oracle
Error 6 'Antlr4.Runtime.ICharStream' does not contain a definition for 'LA' and no extension method 'LA' accepting a first argument of type 'Antlr4.Runtime.ICharStream' could be found (are you missing a using directive or an assembly reference?) C:\gNOSIS\Oracle\Software\oracle\oracle\obj\x64\Debug\Verilog2001Lexer.cs 156 44 oracle
Error 7 'Antlr4.Runtime.ICharStream' does not contain a definition for 'LA' and no extension method 'LA' accepting a first argument of type 'Antlr4.Runtime.ICharStream' could be found (are you missing a using directive or an assembly reference?) C:\gNOSIS\Oracle\Software\oracle\oracle\obj\x64\Debug\Verilog2001Lexer.cs 156 64 oracle
Error 8 'Antlr4.Runtime.ICharStream' does not contain a definition for 'LA' and no extension method 'LA' accepting a first argument of type 'Antlr4.Runtime.ICharStream' could be found (are you missing a using directive or an assembly reference?) C:\gNOSIS\Oracle\Software\oracle\oracle\obj\x64\Debug\Verilog2001Lexer.cs 156 84 oracle
Error 9 The name 'EOF' does not exist in the current context C:\gNOSIS\Oracle\Software\oracle\oracle\obj\x64\Debug\Verilog2001Parser.cs 920 23 oracle
Error 10 'oracle.Verilog2001Parser' does not contain a definition for 'EOF' C:\gNOSIS\Oracle\Software\oracle\oracle\obj\x64\Debug\Verilog2001Parser.cs 875 66 oracle

This, along with a few other related issues, was fixed in the following recent series of commits:
https://github.com/sharwell/antlr4cs/compare/2ac3c964...c0aa59cb
These changes will be included in the next release. Until then you can use the following in your lexer grammar (for combined grammars use #lexer::members):
#members {
public const int EOF = Eof;
public const int HIDDEN = Hidden;
}
Errors 5-8 are related to semantic predicates in your grammar. In the C# target, the lookahead method is La, not LA.

For the "La" / "LA" part you can add some extension methods to fix it:
namespace Antlr4.Runtime
{
public static class AntlrCsCompatability
{
public static int LA(this ICharStream self, int i)
{
return self.La(i: i);
}
}
}
Same holds true for the Lexer:
namespace GeneratedCode.ANTLR4
{
public partial class STLexer
{
public const int EOF = Eof;
public const int HIDDEN = Hidden;
}
}

Related

'TMP_Text' does not contain a definition for 'ignoreRectMaskCulling'

I m trying to run a unity script and every time it throws this error while compiling
'TMP_Text' does not contain a definition for 'ignoreRectMaskCulling'
and no accessible extension method 'ignoreRectMaskCulling' accepting a first argument of type 'TMP_Text' could be found (are you missing a using directive or an assembly reference?)
if (verticalScrollbar != null)
{
textComponent.ignoreRectMaskCulling = true;
verticalScrollbar.onValueChanged.AddListener(OnScrollbarValueChange);
}

Xamarin Microcharts error: The type or namespace name 'Entry' does not exist in the namespace 'Microcharts'

I try to display a chart from Microcharts, but I receive this error:
/Users/pizhev/Documents/WeatherLocationInfo 1.6.8/WeatherLocationInfo/MainPage.xaml.cs(27,27): Error CS0234: The type or namespace name 'Entry' does not exist in the namespace 'Microcharts' (are you missing an assembly reference?) (CS0234) (WeatherLocationInfo)
I fallow this link: Tutorial and before two months this method work perfectly.
So when I try to change:
using Entry = Microcharts.Entry;
to
using Entry = Microcharts.ChartEntry;
I receive a many errors like this:
/Users/pizhev/Documents/WeatherLocationInfo 1.6.8/WeatherLocationInfo/MainPage.xaml.cs(243,243): Error CS1503: Argument 2: cannot convert from 'Xamarin.Forms.Entry' to 'Microcharts.ChartEntry' (CS1503) (WeatherLocationInfo)
and this:
/Users/pizhev/Documents/WeatherLocationInfo 1.6.8/WeatherLocationInfo/MainPage.xaml.cs(44,44): Error CS1061: 'ChartEntry' does not contain a definition for 'Text' and no accessible extension method 'Text' accepting a first argument of type 'ChartEntry' could be found (are you missing a using directive or an assembly reference?) (CS1061) (WeatherLocationInfo)
So what is changed in Microcharts and how can I fix this errors ?

C#: Resolve Missing Assembly Reference for IServiceProvider.QueryService

I am not able to build some C# code because of the following message:
Error CS1061 'IServiceProvider' does not contain a definition for 'QueryService' and no extension method 'QueryService' accepting
a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)
serviceProvider.QueryService(ref SID_STopLevelBrowser, ref guidIServiceProvider, out objIServiceProvider);
Can this be fixed by adding a reference? Which one?
Microsoft.VisualStudio.Data.dll
https://learn.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.data.serviceprovider.microsoft-visualstudio-ole-interop-iserviceprovider-queryservice?view=visualstudiosdk-2019

Open a spreadsheet document from a stream (Open XML SDK)

I'm following the following article about how to work with the OpenXML SDK:
https://msdn.microsoft.com/en-us/library/office/ff478410.aspx
I have the following code:
// Open a SpreadsheetDocument based on a stream.
SpreadsheetDocument spreadsheetDocument
= SpreadsheetDocument.Open(stream, true);
// Add a new worksheet.
WorksheetPart newWorksheetPart = spreadsheetDocument.WorkbookPart.AddNewPart<WorksheetPart>();
newWorksheetPart.Worksheet = new Worksheet(new SheetData());
newWorksheetPart.Worksheet.Save();
Sheets sheets = spreadsheetDocument.WorkbookPart.Workbook.GetFirstChild<Sheets>();
string relationshipId = spreadsheetDocument.WorkbookPart.GetIdOfPart(newWorksheetPart);
// Get a unique ID for the new worksheet.
uint sheetId = 1;
if (sheets.Elements<Sheet>().Count() > 0)
{
sheetId = sheets.Elements<Sheet>().Select(s => s.SheetId.Value).Max() + 1;
}
// Give the new worksheet a name.
string sheetName = "Sheet" + sheetId;
// Append the new worksheet and associate it with the workbook.
Sheet sheet = new Sheet() { Id = relationshipId, SheetId = sheetId, Name = sheetName };
sheets.Append(sheet);
spreadsheetDocument.WorkbookPart.Workbook.Save();
// Close the document handle.
spreadsheetDocument.Close();
But I keep getting the following error:
Severity Code Description Project File Line Suppression State
Error CS1729 'Worksheet' does not contain a constructor that takes 1 arguments MyProject C:\Users\brkar1\Documents\Visual Studio 2015\Projects\MyProject\MyProject\Controllers\HomeController.cs 139 Active
Error CS0246 The type or namespace name 'SheetData' could not be found (are you missing a using directive or an assembly reference?) MyProject C:\Users\brkar1\Documents\Visual Studio 2015\Projects\MyProject\MyProject\Controllers\HomeController.cs 139 Active
Error CS1061 'WorksheetPart' does not contain a definition for 'Worksheet' and no extension method 'Worksheet' accepting a first argument of type 'WorksheetPart' could be found (are you missing a using directive or an assembly reference?) MyProject C:\Users\brkar1\Documents\Visual Studio 2015\Projects\MyProject\MyProject\Controllers\HomeController.cs 140 Active
Error CS1061 'WorkbookPart' does not contain a definition for 'Workbook' and no extension method 'Workbook' accepting a first argument of type 'WorkbookPart' could be found (are you missing a using directive or an assembly reference?) MyProject C:\Users\brkar1\Documents\Visual Studio 2015\Projects\MyProject\MyProject\Controllers\HomeController.cs 142 Active
Error CS1061 'Sheets' does not contain a definition for 'Elements' and no extension method 'Elements' accepting a first argument of type 'Sheets' could be found (are you missing a using directive or an assembly reference?) MyProject C:\Users\brkar1\Documents\Visual Studio 2015\Projects\MyProject\MyProject\Controllers\HomeController.cs 147 Active
Error CS0246 The type or namespace name 'Sheet' could not be found (are you missing a using directive or an assembly reference?) MyProject C:\Users\brkar1\Documents\Visual Studio 2015\Projects\MyProject\MyProject\Controllers\HomeController.cs 147 Active
Error CS1061 'Sheets' does not contain a definition for 'Elements' and no extension method 'Elements' accepting a first argument of type 'Sheets' could be found (are you missing a using directive or an assembly reference?) MyProject C:\Users\brkar1\Documents\Visual Studio 2015\Projects\MyProject\MyProject\Controllers\HomeController.cs 149 Active
Error CS0246 The type or namespace name 'Sheet' could not be found (are you missing a using directive or an assembly reference?) MyProject C:\Users\brkar1\Documents\Visual Studio 2015\Projects\MyProject\MyProject\Controllers\HomeController.cs 149 Active
Error CS0246 The type or namespace name 'Sheet' could not be found (are you missing a using directive or an assembly reference?) MyProject C:\Users\brkar1\Documents\Visual Studio 2015\Projects\MyProject\MyProject\Controllers\HomeController.cs 156 Active
Error CS0246 The type or namespace name 'Sheet' could not be found (are you missing a using directive or an assembly reference?) MyProject C:\Users\brkar1\Documents\Visual Studio 2015\Projects\MyProject\MyProject\Controllers\HomeController.cs 156 Active
Error CS1061 'Sheets' does not contain a definition for 'Append' and no extension method 'Append' accepting a first argument of type 'Sheets' could be found (are you missing a using directive or an assembly reference?) MyProject C:\Users\brkar1\Documents\Visual Studio 2015\Projects\MyProject\MyProject\Controllers\HomeController.cs 157 Active
Error CS1061 'WorkbookPart' does not contain a definition for 'Workbook' and no extension method 'Workbook' accepting a first argument of type 'WorkbookPart' could be found (are you missing a using directive or an assembly reference?) MyProject C:\Users\brkar1\Documents\Visual Studio 2015\Projects\MyProject\MyProject\Controllers\HomeController.cs 158 Active
Why do I get this error messages?
Make sure you have a reference to DocumentFormat.OpenXml.dll added to your project.

EF DB first generates errors when Add Code Generation Items

I'm trying to run the Code Generation for my edmx, however every time I do this, I'm being faced with lots of errors.
This is the Context.cs file is generated:
//------------------------------------------------------------------------------
/ <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace project.DAL
{
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
public partial class NebulabEntities : DbContext
{
public NebulabEntities()
: base("name=NebulabEntities")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public virtual DbSet<Commodity> Commodities { get; set; }
public virtual DbSet<CommoditiesPrice> CommoditiesPrices { get; set; }
}
}
The Errors I'm getting:
Severity Code Description Project File Line
Error CS0426 The type name 'Data' does not exist in the type 'System' project.DAL C:\Test\project.DAL\RedSpiderDataModel.Context.cs 13
Error CS0426 The type name 'Data' does not exist in the type 'System' project.DAL C:\Test\project.DAL\RedSpiderDataModel.Context.cs 14
Error CS0246 The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?) project.DAL C:\Test\project.DAL\RedSpiderDataModel.Context.cs 16
Error CS0115 'NebulabEntities.OnModelCreating(DbModelBuilder)': no suitable method found to override project.DAL C:\Test\project.DAL\RedSpiderDataModel.Context.cs 23
Error CS0246 The type or namespace name 'DbModelBuilder' could not be found (are you missing a using directive or an assembly reference?) project.DAL C:\Test\project.DAL\RedSpiderDataModel.Context.cs 23
Error CS0246 The type or namespace name 'DbSet<Commodity>' could not be found (are you missing a using directive or an assembly reference?) project.DAL C:\Test\project.DAL\RedSpiderDataModel.Context.cs 28
Error CS0246 The type or namespace name 'DbSet<CommoditiesPrice>' could not be found (are you missing a using directive or an assembly reference?) project.DAL C:\Test\project.DAL\RedSpiderDataModel.Context.cs 29
I'm using Visual Studio 2015 for this, and I've added EF to my class library project.
Does anyone know why it's generating code with errors?
This is because you are referencing older entity framework dll in your project. The solution is -
1. First remove the reference of older EF dll from Reference Manager.
2. Then add the Newer EF dll by using the browser feature.
For EF 6.1.3 you will get the dll in the folder "EntityFramework.6.1.3\lib\net45"

Categories